Android 引导接收器未运行
你好,我是新的android开发者。我创建了一个示例项目,该项目在引导完成时运行良好 然后我再次创建我的主项目来使用它,但是启动完成没有执行。。。我尽我最大的努力去发现问题。。我通过清单文件注册了这个接收人,但不实用Android 引导接收器未运行,android,Android,你好,我是新的android开发者。我创建了一个示例项目,该项目在引导完成时运行良好 然后我再次创建我的主项目来使用它,但是启动完成没有执行。。。我尽我最大的努力去发现问题。。我通过清单文件注册了这个接收人,但不实用 public void onReceive(Context context, Intent intent) { // TODO: This method is called when the BroadcastReceiver is receiving // an
public void onReceive(Context context, Intent intent) {
// TODO: This method is called when the BroadcastReceiver is receiving
// an Intent broadcast.
Toast.makeText(context, "boot completed", Toast.LENGTH_LONG).show();
//throw new UnsupportedOperationException("Not yet implemented");
}
并且是清单XML
<receiver
android:name="com.azmizryk.mobilethefttracker.BootCompleted"
android:enabled="true"
android:exported="true" >
</receiver>
在manifest.xml文件中添加以下意图操作
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
i、 e.在您的清单文件中,更改
<receiver
android:name="com.azmizryk.mobilethefttracker.BootCompleted"
android:enabled="true"
android:exported="true" >
</receiver>
到
以下权限在我的ADT中不可用。。我提到,我在示例应用程序中尝试过,就像我在这里展示的一样,我使用了这个权限@user3001551 RECEIVE_BOOT_COMPLETED是您需要添加的权限,BOOT_COMPLETED是一次广播的意图操作,系统完成引导后。@user3001551 BOOT_COMPLETED和QUICKBOOT_POWERON是广播目的操作而非权限,所以按照我的建议更改代码,它会工作的。@user3001551乐于帮助,喜欢编码。您是否使用“启动器”活动手动启动应用程序至少一次?
<receiver
android:name="com.azmizryk.mobilethefttracker.BootCompleted"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>