[英]Bring user back to app when Gmail back button is clicked
I am navigating my app user to Gmail app when he clicks on a certain link inside my app.当我的应用程序用户点击我的应用程序内的某个链接时,我将他的应用程序用户导航到 Gmail 应用程序。 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.但是当用户点击设备上的后退按钮或 Gmail 的工具栏时,他被重定向到 Gmail 收件箱,而不是让用户回到我的应用程序。
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?单击后退按钮或其他一些解决方案来实现此功能时,是否可以将用户带回我的应用程序而不是 Gmail 收件箱? Any help is appreciated任何帮助表示赞赏
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.处理后退按钮应该是 Gmail 应用程序的业务。
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.我曾尝试使用 Gmail 应用程序发送电子邮件。 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.发送电子邮件后,我回到了我的应用程序,但我还没有找到任何方法来实现后退按钮的操作。
Old question but you need to open the Gmail app in new task.老问题,但您需要在新任务中打开 Gmail 应用程序。 add this flag to your intent.将此标志添加到您的意图中。 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.