简体   繁体   English

单击 Gmail 后退按钮时将用户带回应用程序

[英]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.

相关问题 单击设备中的后退按钮时退出应用程序 - Exit the app when back button in device is clicked 单击后退按钮两次时,关闭应用程序 - Close the app when back button clicked twice Android:浏览片段时更改活动标题; 单击返回按钮时带回相同的标题 - Android: Change activity title when navigating fragments; Bring back same titles when back button clicked 看看用户是否单击了后退按钮? - See if user clicked back button? 广告上的“后退”按钮不会将控制权带回android应用 - Back button on an ad does not bring control back to the android app 单击后退按钮两次时是否关闭整个应用程序? - Close entire app when back button clicked twice? Android应用程序对手机的后退按钮做出了正确的反应,但在菜单的后退按钮上单击时,崩溃并显示nulpointerexception - android app reacts properly to to phone's back button but crashes with nulpointerexception when clicked on menu's back button 像Gmail应用程序中一样,Android中的“后退”按钮? - Back button in Android like in Gmail app? 在应用程序上注销 Firebase 后,后退按钮将带回主页 - Back button will bring to home page after firebase logout on app 为什么单击后退按钮时 MainActivity 会重新打开? - Why is MainActivity reopening when the back button is clicked?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM