How to reboot emulator to test ACTION_BOOT_COMPLETED?

前端 未结 7 1617
清歌不尽
清歌不尽 2020-12-23 12:19

Well, I have searched a lot. People say that I need to close the window of emulator to close it. However, I need to reboot the emulator to catch ACTION_BOOT_COMPLETED by my

相关标签:
7条回答
  • 2020-12-23 12:28

    While using tubemate on android tab, I was not successful in downloading video with the error:host interupped etc. I used the following commands:

    adb shell stop
    adb shell start
    

    and the application started downloading videos.

    0 讨论(0)
  • 2020-12-23 12:36

    To emulate a broadcast action, you can connect via adb to the emulator/device and open a shell:

    adb shell
    

    Then, you can broadcast the action you want to test:

    am broadcast -a android.intent.action.BOOT_COMPLETED
    

    Please note that, in the latest Android versions, broadcasting the *android.intent.action.BOOT_COMPLETED* action will actually reboot your emulator/device.

    0 讨论(0)
  • 2020-12-23 12:37

    and another way:

    If you start your emulator, and select the "wipe user data" checkbox, you will also receive that notification when boot is completed.

    0 讨论(0)
  • 2020-12-23 12:39

    You can use the following command from adb:

    adb shell am activity/service/broadcast -a ACTION -c CATEGORY -n NAME
    

    for example:

    adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name
    

    Note that class name and package names need to be as defined in the Manifest.

    This will generate the Intent you want , directed only to the component you want (otherwise you system will go crazy with BOOT_COMPLETED sent...)

    0 讨论(0)
  • 2020-12-23 12:47

    First, make sure that USB Debugging is enabled from within the emulator:

    click:

    • the Home icon
    • Menu icon
    • 'Settings'
    • 'Applications'
    • 'Development'
    • make sure that the box next to 'USB debugging' contains a check mark

    from a command-line:

    adb -e reboot
    

    EDIT:

    This definitely doesn't work... very strange. I tested it and could not make the emulator reboot. It just hangs.

    0 讨论(0)
  • 2020-12-23 12:48

    Or another way (also from the command line):

    adb shell stop
    adb shell start
    
    0 讨论(0)
提交回复
热议问题