broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -


i set simple app. wan't hide drawer , want add boot receiver launch service.

to hide application, read had remove manifest

<intent-filter>     <action android:name="android.intent.action.main" />     <category android:name="android.intent.category.launcher" /> </intent-filter> 

but when remove it, boot receiver doesn't work anymore.

i added permission under manifest tag

<uses-permission android:name="android.permission.receive_boot_completed" /> 

and receiver under application

<receiver android:name="com.example.receiver.bootreceiver" >     <intent-filter>         <action android:name="android.intent.action.boot_completed" />     </intent-filter> </receiver> 

and in receiver code, there toast

public class bootreceiver extends broadcastreceiver {      @override     public void onreceive(context context, intent intent) {         toast.maketext(context, "boot received", toast.length_short).show();     } } 

why couldn't set boot receiver , hidden app drawer?

thanks

starting android 3.1 applications, upon installation, placed in "stopped" state.(this same state application ends in after user force-stops app settings application.)

android stopped state

while in "stopped" state, application will not run reason, except manual launch of activity. (meaning no broadcastreceviers(action_package_installed, boot_completed etc.) invoked, regardless of event have registered, until user runs app manually.)

this anti-malware move google. google has advocated users should launch activity launcher first, before application can go much. preventing boot_completed being delivered until activity launched logical consequence of argument.

more details this:
http://developer.android.com/about/versions/android-3.1.html#launchcontrols
http://commonsware.com/blog/2011/07/05/boot-completed-regression.html
http://devmaze.wordpress.com/2011/12/05/activating-applications/


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -