[英]Intent opens the app immediately when app is in background -Android
I have a Dialog themed activity that I call on my FirebaseFunction onMessageReceived(), with this I am attempting to display a dialog on the phone's screen if the app is in the background. 我有一个Dialog主题活动,我在我的FirebaseFunction onMessageReceived()上调用,如果应用程序在后台,我试图在手机屏幕上显示一个对话框。 However:
然而:
1- If the app is closed: it works perfectly I can see the dialog in my main screen. 1-如果应用程序已关闭:它完美运行我可以在主屏幕中看到对话框。
2- If the app is in open, but in the background (I can see it on my recent-apps) it opens the app immediately like if onResume()/onRestart() was called. 2-如果应用程序处于打开状态,但在后台(我可以在我最近的应用程序中看到它),它会立即打开应用程序,就像调用onResume()/ onRestart()一样。
I want the dialog to display if app is in the background as well as when the app is closed, I am sure the problem is on how I am passing the intent, not sure how to fix it. 我希望对话框显示如果应用程序在后台以及应用程序关闭时,我确定问题在于我如何传递意图,不知道如何修复它。
it should solve your problem. 它应该解决你的问题。
<activity ...
android:launchMode="singleTop" />
Intent intent= new Intent(context, YourActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
You need to put this new flag! 你需要把这个新旗子!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.