My BroadcastReceiver doesn't get BOOT_COMPLETED intentions after my N1 boots

I cannot get the BroadcastReceiver onReceive method called using the BOOT_COMPLETED intent.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jerrellmardis.umbrella" android:versionCode="4" android:versionName="1.0.3"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> <activity android:name=".activities.Umbrella" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".activities.Preferences" android:label="@string/app_name" android:screenOrientation="portrait" /> <receiver android:name="com.jerrellmardis.umbrella.receiver.WeatherStartupReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <service android:name=".service.WeatherUpdateService"> <intent-filter> <action android:name="com.jerrellmardis.umbrella.service.WeatherUpdateService" /> </intent-filter> </service> </application> <uses-sdk android:minSdkVersion="3" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> </manifest> 

WeatherStartupReceiver.java

 package com.jerrellmardis.umbrella.receiver; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.provider.Contacts.People; import android.util.Log; import com.jerrellmardis.umbrella.R; public class WeatherStartupReceiver extends BroadcastReceiver { private NotificationManager mNotificationManager; private int SIMPLE_NOTFICATION_ID; @Override public void onReceive(Context context, Intent intent) { // Do something interesting here... } } 
+7
android android-intent service broadcastreceiver intentfilter
source share
2 answers

All applications that receive BOOT_COMPLETED broadcasts must be installed in the internal storage, since Android delivers ACTION_BOOT_COMPLETED before the external storage is installed on the device.

To make sure your application is installed in internal memory, you just need NOT to declare the android:installLocation manifest attribute.

Another option is to set the following in the manifest section: android:installLocation="internalOnly"

You can find more information about this here .

+15
source share

EDIT: Forget everything, I found a better explanation.

You must define your receiver with exported = true and enabled = true

 <receiver android:name="com.jerrellmardis.umbrella.receiver.WeatherStartupReceiver" android:enabled="true" android:exported="true" > 

I think if you change this line

 <receiver android:name="com.jerrellmardis.umbrella.receiver.WeatherStartupReceiver"> 

for this

 <receiver android:name=".WeatherStartupReceiver"> 

he will fix your problem.

I tried this in one of my projects and it did not start.

+2
source share