Reboot receiver is not working in xiaomi phones

白昼怎懂夜的黑 提交于 2019-11-30 16:38:18

问题


Hi We are working on an android application where we are using reboot receiver in which I am starting few services where I am performaning some network operation.

I figured it out that in some android devices like xiaomi etc reboot receiver is not working.

Earlier I got to know that In HTC devices also it does not work so I added one more intent filter to it <action android:name="android.intent.action.QUICKBOOT_POWERON" /> then it started working fine. Now other phones like xiaomi it's still not working.

What I have to set additionally so it works fine in all the devices without asking user to update any settings manually.

<receiver
    android:name="com.xyz.broadcastreceiver.ServiceStarter"
    android:exported="true" >
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="android.intent.action.QUICKBOOT_POWERON" />
    </intent-filter>
</receiver>

Thanks in advance.


回答1:


Xiaomi phones running MIUI have a inbuilt startup apps blocker. Maybe that is interfering with your boot receiver.




回答2:


Ok, let's try again. MIUI has a a built-in Security app. In the Security app there is a 'Startup' section, where the user can configure which app can and which app can't run on startup. Your application is disabled default. Also if you examine your Logcat you can see a "permission denied" message at startup. Put your app manually to the whitelisted apps, unfortunately that is your users can only do.




回答3:


Add this in your manifest file in intent-filter

<action android:name="android.intent.action.BOOT_COMPLETED" />



回答4:


Try adding the android.intent.category.DEFAULT category. It is mandatory for implicit intents, but maybe it is being tweaked for some reason in Xiaomi phones and the intent is not passing one of the tests to being received by your application.




回答5:


There is an internal feature of MIUI which prevents apps from restarting for saving battery & RAM. You have to manually toggle Auto Start option on in order to receive broadcast for BOOT_COMPLETED. Go to Settings> Installed Apps> Your App. Then just toggle on the auto start option. There is no option to prevent this programmatically. Instead, you can inform your app's users if they face problems while using your app (ex: Alarm is not triggering properly), they can enable Auto Start from Settings.




回答6:


Xiomi has a reported bug for only using this reciever 5 minutes after the system
actually boot-up -
http://xiaomi.eu/community/threads/alarmmanager-_wakeup-problem.21430/
You can try and add the -

android:enabled="true" and android:exported="true"
even though they should be set to true by default due to manufacturer system changes
it might be different on Xiomi android customized OS.
Just pay attention for their meaning
Since the android:exported="true"
Will let other applications access to your reciever.




回答7:


You need to add

android:enabled="true"

and

android:exported="true"

exported can be false, but it is necessary to include exported.

I think it's a problem with ROM Xiaomi.eu, tested with the dev version, I used the MIUI 6.5.19 Beta version 7.4 on a Xiaomi Redmi Note 2 Prime. I have not checked with the stable version that can not be downloaded at this time for server maintenance. Broadcast receiver doesn't work on boot.

Probe the same app in a Xiaomi Mi 4 with stable Xiaomi Global ROM, MIUI 7.1.2, there worked perfectly after activating the autostart in the manager. Restart and perfectly worked the broadcast receiver and permissions required.

Now, I tested with Xiaomi.EU 7.3 stable, MIUI 7.3.2, Broadcast receiver works fine on boot and reboot. I registered my receiver with autostart in security manager, it doesn't work in ROM dev version. I don't tested with Xiaomi Official ROM Global dev.

My permissions:

<receiver android:name=".service.BootBroadcastReceiver"
  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"/>
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</receiver>



回答8:


you should see here. In Xiaomi devices, they block some permissions even if you require it. The only way to slove it is you must allow your app this permission manually.




回答9:


I was suggesting to add android:enabled="true" but it was already offered.

So I can tell you that you first make sure yourself if the receiver registered properly or not. You can also try the other version of registering it - that is doing registration programmatically (preferably in onPause() & onResume()) and see if it's receiving the broadcast message or not.




回答10:


Try to disable the MUIU Optimization from the Developer Options. It worked for me.

1- Go to Settings

2- Open Additional Settings

3- Open Developer Options

4- Find the Turn on MIUI optimization

5- Disable the switch button.



来源:https://stackoverflow.com/questions/29627856/reboot-receiver-is-not-working-in-xiaomi-phones

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