android - 如何测试 BOOT_COMPLETED 广播接收器

标签 android android-emulator genymotion android-broadcastreceiver reboot

我想在模拟器中使用操作 BOOT_COMPLETED 检查 BROADCAST RECEIVER。

这是我的代码

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) {

}

<receiver
        android:name=".AutoRunService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

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

提前致谢。

最佳答案

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

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -p com.example.package

关于android - 如何测试 BOOT_COMPLETED 广播接收器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42949674/

相关文章:

android - 如何在android studio中安装genymotion插件?

android - getBluetoothLeAdvertiser() 返回 null

java - Android,内部有多个 View 的滚动菜单 - 来自 XML 的 View

android - Geo Fix 命令不通过高度

android - 在 Genymotion 中安装 Facebook APK

android - 无法使用 Android 版本 4.0.3 创建模拟器

android - 如何让Android Gradle构建写入调试APK的文件

android - 使用模拟器使用 android NFC

android - 使用新版 Admob Ads 附加 google play 服务时应用程序大小会增加吗?

android - 如何向我的 ListView 项目添加微调器功能?