android.intent.action.MY_PACKAGE_REPLACED Not getting triggered - android

I have this receiver declared in my Manifest file. I am receiving the broadcast in one phone that is Samsung Note 2 Jelly bean but not receiving the broadcast on another phone, Redmi 4.4.4. Please let me know what might be the issue.
<receiver
android:name=".UpgradeReceiver"
android:enabled="true"
android:exported="false">
<intent-filter android:priority="999" >
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>

Related

How to receive BOOT_COMPLETED on Android TV

I'm developing an app for Android TV. I have a sticky service & a broadcast receiver that should restart this service after system reboot.
The code works perfect for any phone, but, in the case of the TV, any of the actions that I defined in the receiver's intent isn't received, when turning on the TV from standby(using the remote). It works when I unplug the TV and plug it again.
Has anyone tried something similiar? Any advice might help. Thanks
I've tried BOOT_COMPLETED, QUICKBOOT_POWERON, REBOOT, ACTION_POWER_CONNECTED.
Here is the receiver I've configured.
<receiver
android:name=".MyReceiver"
android:directBootAware="true"
android:enabled="true"
android:exported="true">
<intent-filter>
<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="android.intent.action.LOCKED_BOOT_COMPLETED" />
<action
android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Expected to catch the action of turning on the device in the broadcast.
Please check if you have added following permission.
uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"

android.intent.action.TIME_SET in marshmallow not working

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>

BOOT_COMPLETED not triggered on a Gionee device with Lollipop ver

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>

Launching application when receiving on DATA_SMS_RECEIVED

I have declared a broadcast receiver in manifest for receiving DATA_SMS_RECEIVED, the broadcast receiver triggered when the application is running, but when the application is closed nothing happens and no broadcasts are received.
<receiver android:name="edu.sharif.iis.khasis.SmsReceiver" android:exported="true" android:enabled="true">
<intent-filter android:priority="999">
<action android:name="android.intent.action.DATA_SMS_RECEIVED"/>
<data android:scheme="sms" android:host="*" android:port="8901" />
</intent-filter>
</receiver>
I have tested this scheme with BOOT_COMPLETED and it works well, but doesn't works with DATA_SMS_RECEIVED. could someone tell me what is the problem?
Add this
<action android:name="android.permission.RECEIVE_SMS" />
It is OS generated action.

is having two broadcast receivers valid in android?

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.

Categories

Resources