应用程序启动行为并不总是相同
application launch behavior is not always the same
我目前在 Android 上遇到一个我不明白的问题。
例如,我安装了 exoplayer 演示 android 应用程序,并按照以下说明操作:
- 点击图标启动应用程序
- 浏览应用程序
- 将应用置于后台
- 点击图标重新启动应用程序
预期行为:系统恢复我的应用程序
当前行为:系统恢复我的应用程序(太棒了!)
你可以在这里看到结果:https://youtu.be/BGyr_BpJQUY
现在我模拟用户从 Google Play 商店打开应用程序(例如)点击 "open" 按钮,所以我执行以下指令:
- 在终端中:adb shell
- 使用命令行启动应用程序:am start -n com.google.android.exoplayer2.demo/.SampleChooserActivity
- 浏览应用程序
- 将应用置于后台
- 点击图标重新启动应用程序
预期行为:系统恢复我的应用程序
当前行为:系统重启我的应用程序(糟糕!)
你可以在这里看到结果:https://youtu.be/nNnYQUrrU4o
在第二种情况下,我没有进入 onDestroy 生活事件(在我的 activity 或我的片段中)所以它破坏了其中的工作流程...
有办法处理这种情况吗?有人能给我解释一下这个问题吗?
感谢您的帮助!
@ABS在评论中给出正确答案:
Check if this works and is same as google play intent: adb shell am start -n "app.package.name/activity.package.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
我目前在 Android 上遇到一个我不明白的问题。
例如,我安装了 exoplayer 演示 android 应用程序,并按照以下说明操作:
- 点击图标启动应用程序
- 浏览应用程序
- 将应用置于后台
- 点击图标重新启动应用程序
预期行为:系统恢复我的应用程序
当前行为:系统恢复我的应用程序(太棒了!)
你可以在这里看到结果:https://youtu.be/BGyr_BpJQUY
现在我模拟用户从 Google Play 商店打开应用程序(例如)点击 "open" 按钮,所以我执行以下指令:
- 在终端中:adb shell
- 使用命令行启动应用程序:am start -n com.google.android.exoplayer2.demo/.SampleChooserActivity
- 浏览应用程序
- 将应用置于后台
- 点击图标重新启动应用程序
预期行为:系统恢复我的应用程序
当前行为:系统重启我的应用程序(糟糕!)
你可以在这里看到结果:https://youtu.be/nNnYQUrrU4o
在第二种情况下,我没有进入 onDestroy 生活事件(在我的 activity 或我的片段中)所以它破坏了其中的工作流程...
有办法处理这种情况吗?有人能给我解释一下这个问题吗?
感谢您的帮助!
@ABS在评论中给出正确答案:
Check if this works and is same as google play intent: adb shell am start -n "app.package.name/activity.package.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER