我正在开发一些应用程序需要在重启重新设定报警为什么receive_boot_completed在我的设备上不起作用?
这是正确的仿真器和三星标签2 10.1工作使用receive_boot_completed
..但它不工作我的星系微型设备上使用Android 2.2版本.1 !!!
这在我的代码:
的manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.engahmedphp.collector"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.engahmedphp.collector.SplashActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PagesActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".FeedsActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name" >
</activity>
<activity
android:name=".PagePrefsActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ManagePagesActivity"
android:launchMode="singleTask"
android:label="@string/app_name" >
</activity>
<activity
android:name=".FeedsDialogActivity"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.Dialog"
>
</activity>
<receiver android:name=".FeedsReceiver" >
</receiver>
<receiver android:name=".BootCompletedReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
<service android:name=".GetFeedsService" >
</service>
<service android:name=".ResetAlarmsService" >
</service>
</application>
</manifest>
BootCompletedReceiver.java
package com.engahmedphp.facebookcollector;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class BootCompletedReceiver extends BroadcastReceiver {
// ==============================================================================
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "nice", Toast.LENGTH_LONG).show();
Log.e("boot", "boot");
Intent resetAlarms = new Intent(context, ResetAlarmsService.class);
context.startService(resetAlarms);
}
}
我测试你的代码在我的设备上,它工作正常。在收到意图之前,您是否至少启动了一次该应用程序? – SLee
不,我不打开它,它应该显示烤面包,它不工作..你的设备是在2.2.1? –
我在2.2.2上测试过。我的意思是启动应用程序至少一次,然后重新启动系统。 – SLee