I am trying to execute the OnReceive method when Android starts so that I can schedule a task.
Unfortunately onReceive of my BradcastReciever is called at boot only if I install the app on the root system. I thought that android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE should fix the problem.
But from this post it seems that it is not possible, though in certain tutorials they say it is feasible.
Android installLocation and BOOT_COMPLETED
I should infer that I cannot do such a thing.
Is that really so or there is a way to get the broadcast at startup with my app on the sd.
If it is not possible I wonder what's the use of android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE
This is my Manifest in case someone wnat to take a look. I am testing on Android 2.3.7
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mypackage"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<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" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
.............................
<receiver
android:name="mypackage.MyNotificationReceiver"
android:enabled="true"
>
<intent-filter android:priority="1" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
</intent-filter>
</receiver>
</application>
</manifest>
Thanks
First you have to split intent filter Something like this:
<receiver
android:name="mypackage.MyNotificationReceiver"
android:enabled="true"
>
<intent-filter android:priority="1" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
</intent-filter>
</receiver>
Every filter should have only one action. Second, a question: ACTION_EXTERNAL_APPLICATIONS_AVAILABLE occurs always some time after BOOT_COMPLETED (the device first completes boot, then reads card). So why both actions?