gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 01:11:06 25 4
gpt4 key购买 nike

我想在模拟器中使用操作 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com