![](/img/trans.png)
[英]ReactJS app in Android webview - Pressing back button closes app
[英]Launching an app via intent and then pressing back button closes the parent app as well
当用户单击按钮时,我正在启动 gmail 应用程序。 这是我在 android 上打开 gmail 应用程序的代码,我正在使用android_intent
package。
const intent = AndroidIntent(
action: 'android.intent.action.MAIN',
category: 'android.intent.category.APP_EMAIL',
);
intent.launch().catchError((e) {
context.showMessageDialog(e.toString());
});
它会正确打开gmail
应用程序,现在当我单击 android 中的后退按钮时,它会关闭gmail
以及我的应用程序。 我不希望它关闭我的应用程序。 我希望gmail
作为不同的应用程序打开。 我不能使用url_launcher
package,因为它用于发送 email。 我的用例只是打开用户的 email 应用程序,以便用户可以验证我在注册期间从后端发送的 email。
这对我有用:
private fun openGmail() {
val intent = requireContext().packageManager.getLaunchIntentForPackage("com.google.android.gm") //"leanback" version is for TV
startActivity(intent)
}
在AndroidManifest.xml
android:launchMode="singleTop"
更改为android:launchMode="singleInstance"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.