I am trying to solve a start on boot related problem and I noticed many examples of the AndroidManifest.xml which has android.intent.action.BOOT_COMPLETED and some that also have the category of android.intent.category.HOME in there. Does anyone know what the difference (if any) between the two are?
ie.
<receiver android:name=".MartiniBootBroadCastReciever"
android:enabled="true" android:exported="false"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
versus
<receiver android:name=".MartiniBootBroadCastReciever"
android:enabled="true" android:exported="false"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
AFAIK, your first one is wrong. The BOOT_COMPLETED broadcast should not have that category, AFAIK.
Related
I have broadcast receiver for date change event, it works fine for kitkat and lolipop version but not working in marshmallow.
code is as follow
<receiver
android:name=".DateChangedReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.TIME_SET" />
</intent-filter>
</receiver>
what should I do for that? is their any special permission required? Please help
You are right . This intent action may be restricted to system apps only . Adding the android:permission="android.permission.BIND_DEVICE_ADMIN" to the receiver is working for me .
PFB update receiver definition
<receiver
android:name=".DateChangedReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_DEVICE_ADMIN"
>
<intent-filter>
<action android:name="android.intent.action.TIME_SET" />
</intent-filter>
</receiver>
UPDATE : I am receiving BOOT_COMPLETED on Gionee but only if I follow these steps -
1. Open "Auto start" and then close it
2. Open the app and close it
If I do above steps and then turn off and on the phone, BOOT_COMPLETED gets triggered. Next time if I just turn it off and on, it is not triggered. Am able to simulate this consistently. What might be the reason ?
I have this declared in the manifest. It is working on phones like Samsung, Motorola etc but on Gionee I found that the receiver is not getting triggered on phone bootup. The phone has Lollipop ver. Please let me know what might be missing here. Appreciate your help.
<receiver
android:name=".BootUpReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.REBOOT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
This worked on my Gionee Phone:
<receiver
android:name=".BootUpReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.REBOOT" />
<action android:name="com.gionee.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
I am trying to make an existing android app wearable.
Is it necessary, or not, to specify the full package path for setting a media button event receiver?
I haven't seen any explanation in the official documentation. It is as follows in the documentation:
<receiver android:name=".RemoteControlReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
While I have this in my current code:
<receiver android:name="com.pckg.my.app.subpack.RemoteControlReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
Try to add (.) in the beginning of your android name
<receiver android:name=".com.pckg.my.app.subpack.RemoteControlReceiver">
i don't know if this is okay having two broadcast receivers in my android app. I separated them cause the one receiver with the boot_completed, it will do a different task and the other receiver with also do different task when they receive a broadcast.
<receiver android:name=".Autostart">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver
android:name=".AlarmManagerBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
That is perfectly valid you should always try to seperate your concerns which part of a good architecture/good design principles.
I have a Receiver like so in my Manifest:
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
I saw here on StackOPancakes one like so:
<receiver android:name=".BootupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
What is the purpose/advantage of the "HOME" category assignment?
Actually, from the documentation we can read that categories like "android.intent.category.HOME" and "android.intent.category.LAUNCHER" are used to group activities into some sets. For instance, "android.intent.category.LAUNCHER" is used by Launcher application to select applications that can be launch. Similarly, for an intent-filter for an activity with category "android.intent.category.HOME" is used to find a home screen.
But with BroadcastReceivers I think this category is used as additional category test.