简体   繁体   English

Android Intent通过重新启动应用程序生存/ Airbnb深度链接通过重新启动应用程序生存

[英]Android Intent survives through app relaunch / Airbnb deep link survives through app relaunch

We used this Airbnb deep link dispatch lib in our app. 我们在应用程序中使用了此Airbnb深度链接分发库。
https://github.com/airbnb/DeepLinkDispatch https://github.com/airbnb/DeepLinkDispatch

Below is the issue app is facing. 以下是应用程序面临的问题。

  1. Kill app. 杀死应用程序。
  2. Launch app with deep link. 启动具有深层链接的应用程序。 That opened, say, a dialog on top of activity. 例如,这打开了活动顶部的对话框。
  3. press back key on app and close it. 在应用程序上按返回键并关闭它。
  4. Launch it again through Recent Tasks. 通过“最近的任务”再次启动它。
    Dialog shows up again. 对话框再次出现。 Repeat steps, it shows up again. 重复步骤,它再次显示。
    This is mostly because on back key, process is not dead and activity has overrides onSaveInstanceState() and onRestoreInstanceState(). 这主要是因为在返回键上,进程没有死,并且活动具有覆盖onSaveInstanceState()和onRestoreInstanceState()的功能。 I see in onCreate() that getIntent() returns the intent with same previous deep link. 我在onCreate()中看到getIntent()返回与先前的深层链接相同的意图。 Hence the problem. 因此出现了问题。
    This does not happen if I launch app from home screen in which case it posts the launch home intent so the previous intent could have been replaced with it and so gone. 如果我从主屏幕启动应用程序,则不会发生这种情况,在这种情况下,它会发布启动主界面意图,因此以前的意图可能已被它替换并因此消失了。

I know it is how it works in Android. 我知道这是Android中的工作方式。 But is there a way in this lib or in Android to solve it ? 但是在这个lib或Android中有没有解决的方法?

It was not an issue with Airbnb library but that is how it works with Android. 这不是Airbnb库的问题,而是Android系统的工作方式。 When launched from recents after killing app with back key , Android posts the previous intent that was used to launch app. 在使用后退键杀死应用程序后从最新消息启动时,Android会发布用于启动应用程序的先前意图。
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS indicates if app launched from history/recent screen. Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS指示应用程序是否从历史/最近屏幕启动。 This flag can be used to handle any logic. 该标志可用于处理任何逻辑。

Credits to this sof post 归功于此sof帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM