So, I have this code to create an email Intent so my users can send support mail.
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"username#example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "The subject");
i.putExtra(Intent.EXTRA_TEXT, "The body");
startActivity(Intent.createChooser(i, "Send email"));
With that code, it opens up a dialog where I will choose which app will I use to send email. When I press the Back button, it returns to Home screen and also if I tap to somewhere else to close the dialog. And when I choose an app, Gmail for example, it opens up Gmail (I can now send email), but when I press send it also goes back to Home screen and also if I press the Back button.
Now, my question is how to return to the previous Activity press I press Back button and if I want to cancel sending mail? Also for the dialog when I want to cancel it.
Try this for Email, filters way better:
Intent feedback = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + "SUBJECT"
+ "&body=" + "BODY" + "&to="
+ "EMAILADRESS");
feedback.setData(data);
startActivity(feedback);
This did a great job for me
Related
I am navigating my app user to Gmail app when he clicks on a certain link inside my app. The redirection is working fine. But when the user hits the back button on the device or the toolbar of Gmail, he is redirected to Gmail inbox instead of getting the user back to my app.
I am doing something like so :-
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "some#email.address" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));
Is there a way the user can be taken back to my app instead of Gmail inbox when clicked on back button, or some other solution to achieve this functionality? Any help is appreciated
Old question but you need to open the Gmail app in new task. add this flag to your intent.
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
I am not sure if it is possible as you redirect the user to the another app which is another scope. Handling of the back button should be Gmail App's business then.
I also would like to know if there is any way to do it.
String mailto = "mailto:mailaddress1#domain.com" +
"?cc=" + "mailto:mailaddress2#domain.com" +
"&subject=" + Uri.encode("subject") +
"&body=" + Uri.encode("text is here");
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse(mailto));
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e)
//TODO: Handle case where no email app is available
}
I have tried to send an e-mail using Gmail App. After sending an e-mail, I got back to my app but I have not found any way to implement an action for back button.
With the code below I share some text from my app via an intent chooser. My problem is that if I for example choose to share the text as a message and when in the message app I just hit the home button and bring my app back to front. Then when I try to start a new intent chooser it immediately sends me back to the unfinished message app. I would rather that it forgot all about that and presented me with the list of choices again.
Is there a way to make it forget the old choice?
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, "Share text as..."));
Add the following
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
I would like to share something from my application.
Once it is shared (e.g - message sent), I want my application to be active again and the sending app to disappear.
Using the code below, I expected onActivityResult to be called, but it is never called.
After sending email, my application appears again, but after sending SMS ('Messaging') the messaging app remains. (onActivityResult is never called)
Thanks :-)
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "This is a test";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "You have to see this!");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivityForResult(Intent.createChooser(sharingIntent, "Share via"),1);
getFragmentManager().popBackStack();
This will only be called if the user presses the back button. Because you are starting a new intent, so you give control to another application.
So normally, if the user presses the back button (which I would do as an Android user) the user will go back to your app. This the way I would prefer to use for this case, and as far as I know it is also the only way to do this in Android.
enter code hereI am using mail composing option from my app i.e when i click on submit button i am navigating the user to the mail composing page.
Now i want to return to a specific activity on either case
1- on success full send . navigate to activity2
2- on Discard navigate to activity1
how can i do that
the code is following
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] {
"sales#fastpkg.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Placing an Order");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is a
sample mail..");
emailIntent.setType("text/plain");
startActivity(Intent.createChooser(emailIntent, "Send mail client :"));
I think, if you use
startActivityForResult(Intent.createChooser(emailIntent, "Send mail client :"),RESULT_OK);
You can always navigate to your activity (Land at onActivityResult() of your current Activity) from which you have started the above activity either its success or when you press back key from started activity.
I am trying to show activity chooser menu when dialing a number. Following code works for me when sending an email (from real phone,doesn't work in emulator):
/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to#email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
/* Send it off to the Activity-Chooser */
this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
But when I change the code as:
Intent call = new Intent(android.content.Intent.ACTION_CALL);
call.setData(Uri.parse("tel:" + phoneNo));
this.startActivity(Intent.createChooser(call, "Hello there..."));
No activity chooser menu is shown, just straight dial. I also want to list skype in that menu. Do you have any idea?
As someone else answered in one of your previous questions, you really do need to read up on Intents and Filters. I'll give you a quick explanation though. An Intent is a type of message that Android applications can register to handle. If Skype is not installed, then it won't be able to register for that Intent and so won't show up in that menu. If it is installed and still doesn't show up, that means it's not registered for that Intent. I don't know the Android Skype app, but judging from the picture you linked in the other question, it seems that it does register for that Intent and will show up when installed.