如何测试 BOOT_COMPLETED 广播接收器

Bek*_*aKK 5 android reboot android-emulator genymotion android-broadcastreceiver

我想在模拟器中使用操作 BOOT_COMPLETED 检查广播接收器。

这是我的代码

public class AutoRunService extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
        Toast.makeText(UApplication.getInstance(), "Application is ready to open ", Toast.LENGTH_SHORT).show();

        myFunciton(context);

    }
}

public void myFunciton(Context context) {

}
Run Code Online (Sandbox Code Playgroud)

}

<receiver
        android:name=".AutoRunService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

我正在使用 Windows 10 和 genymotion 模拟器。有什么方法可以检查模拟器中的广播接收器吗?我如何重新启动模拟器来检查该接收器?有直接命令吗?

提前致谢。

amo*_*the 3

转到 adb 工具 -> 转到 adb shell 并使用以下命令

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -p com.example.package
Run Code Online (Sandbox Code Playgroud)