How to start an application using android ADB tools?

后端 未结 11 1213
醉酒成梦
醉酒成梦 2020-11-22 07:23

How do I send an intent using Android\'s ADB tools?

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 07:57

    Also, I want to mention one more thing.

    When you start an application from adb shell am, it automatically adds FLAG_ACTIVITY_NEW_TASK flag which makes behavior change. See the code.

    For example, if you launch Play Store activity from adb shell am, pressing 'Back' button(hardware back button) wouldn't take you your app, instead it would take you previous Play Store activity if there was some(If there was not Play store task, then it would take you your app). FLAG_ACTIVITY_NEW_TASK documentation says :

    if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in

    This caused me to spend a few hours to find out what went wrong.

    So, keep in mind that adb shell am add FLAG_ACTIVITY_NEW_TASK flag.

提交回复
热议问题