Android - How to start an application on the /sdcard after boot

萝らか妹 提交于 2019-12-04 00:06:16
Rahul Chaudhary

Please mention it in manifest file.

</uses-permission>    
<receiver android:name=".BootReceiver"
    android:enabled="true"
    android:exported="true"
    android:label="BootReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"></action>
    </intent-filter>
</receiver>

provide permission "android.permission.RECEIVE_BOOT_COMPLETED" as child of menifest.

and one more thing your app must not be installed in sdcard.

According to Google, you should not put any app you want to run at boot on an external drive.

"The system delivers the ACTION_BOOT_COMPLETED broadcast before the external storage is mounted to the device. If your application is installed on the external storage, it can never receive this broadcast."

http://developer.android.com/guide/topics/data/install-location.html#ShouldNot

Kamran Ahmed

I usually register every intent filter for a broadcast receiver both ways (Android Manifest as well as dynamically in a class that extends Application)

In AndroidManifest.xml as:

    <receiver
            android:name=".broadcastReciever"
            android:enabled="true"
            android:exported="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE" />
            </intent-filter>
        </receiver>

and in a class that extends Application:

registerReceiver(new broadcastReciever(), new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE));

and don't forget to add RECEIVE_BOOT_COMPLETED permission and register the class which extends Application in the Android Manifest.

This should do; feel free to ask for any more help/clarification.

try using <receiver android:name=".BootCompleteReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver>

and this <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

perhaps QUICKBOOT_POWERON help u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!