i am developing some app need to use receive_boot_completed
on rebooting to reset some alarms
it 's working properly on emulator and Samsung tab 2 10.1 .. but it isn't working on my galaxy mini device with android version 2.2.1 !!!
this in my code :
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);
}
}
try to put this line in your receiver's intent-filter.
<action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
If your application is installed on the SD card, you should register this to get the android.intent.action.BOOT_COMPLETED event.
Updated: Since your app is using alarm service, it should not be installed on external storage. Reference: http://developer.android.com/guide/topics/data/install-location.html