So I have an editText in an app I created, the aim of this editText is to send a piece of text information. I want the user to be able to send text information for me to use, it's kinda like when you have a "FeedBack" option and the user has to fill it with the required information needed, I want to be able to get this information somehow. Pls help, I'm still new to the mobile app development thing. :)
Asked
Active
Viewed 40 times
-1
-
editText.getText() i guess. Or what you are talking about when you say "get"? – Lenin Nov 14 '19 at 20:32
-
Does this answer your question? [Get Value of a Edit Text field](https://stackoverflow.com/questions/4531396/get-value-of-a-edit-text-field) – otto Nov 14 '19 at 21:00
-
What I mean is, I want to receive the text information the user inputs. Just like when someone sends you a message on facebook and you get it on your phone. That sort of thing. But it doesn't necessarily need to be like a chat kind of thing. Do you understand? – maykhid Nov 14 '19 at 21:01
-
@otto Thanks, but that's not what I meant. – maykhid Nov 14 '19 at 21:04
-
How do you want to receive it? By E-Mail? – otto Nov 14 '19 at 21:17
-
Well, that could work. But is there like a better option to work with? Thanks. – maykhid Nov 14 '19 at 21:23
2 Answers
0
Use getText()
on your EditText. This will return an Editable which can be casted to String if you want:
String feedback = editTextFeedback.getText().toString();
If you want to receive the input by mail:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try { startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

otto
- 190
- 1
- 7
0
What you can do is opening a "share" activity and send the text through any app you have in the phone (whatsapp, telegram, mail, etc).
public void share(message: String) {
try {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Sending message");
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
Intent.createChooser(shareIntent, "Share with");
} catch (Exception e) {
e.printStackTrace()
}
}
This will open a window like this:

Lenin
- 500
- 3
- 11
-
Sorry bro but this isn't exactly wanted. Let's say for example I create an app that has a text box (EditText) that requires the user to input certain details I would like to have so that when the user presses the send button I receive this information at my end. Does it make sense now? – maykhid Nov 16 '19 at 19:10