【发布时间】:2014-06-23 18:18:25
【问题描述】:
在启动完成时,我正在启动一个在模拟器上完美运行的服务,但是当我在 android 手机上运行它时,广播接收器不会启动服务。 Infact 应用甚至没有从设备接收启动完成广播。
这是我的清单文件:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_logo"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name="com.darkrai.smsbasedcontroller.BootReciever"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</application>
这是我的广播接收器类。
public class BootReciever extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, UpdateService.class));
Log.d("Boot", "Boot Reciever");
}
【问题讨论】: