嗨我们正在开发一个Android应用程序,我们正在使用重启接收器,我正在启动一些服务,我正在执行一些网络操作.
我想通了,在像xiaomi等一些Android设备中,重启接收器无法正常工作.
早些时候我知道在HTC设备中它也不起作用所以我再添加一个intent过滤器<action android:name="android.intent.action.QUICKBOOT_POWERON" />然后它开始工作正常.现在像小米这样的其他手机仍然没有用.
我必须另外设置,以便它在所有设备中正常工作,而无需用户手动更新任何设置.
<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>
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我目前正在开发一个包含Boot_Completed Broadcast接收器概念的应用程序.我已经在我的摩托罗拉Moto G手机中测试了这款应用.该应用程序运行正常,并显示Toast消息.但是当我在XIAOMI Redmi 1S手机中测试这个应用程序时,它不会显示Toast消息.
我已经看到很多类似于我的问题的问题(如 问题1,问题2等)......但我没有解决这个问题.
我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demoapp"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="internalOnly" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.demoapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.example.demoapp.MyReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
MyReceiver.java
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if ("android.intent.action.BOOT_COMPLETED".equalsIgnoreCase(intent.getAction())) …Run Code Online (Sandbox Code Playgroud)