BOOT COMPLETE没有在Android平台(红米手机) [英] BOOT COMPLETE is not working in Android (Redmi)
问题描述
我目前工作的一个应用程序,其中包括Boot_Completed广播接收器的概念。我在我的摩托罗拉Moto G的电话测试这个程序。该应用程序运行正常并显示敬酒消息。但是,当我测试这个程序中的小蜜红米手机1S 手机不显示敬酒消息。
I am currently working on a application which includes Boot_Completed Broadcast receiver concept. I have tested this app in my Motorola Moto G Phone. The app runs fine and shows the Toast message. But when I test this app in XIAOMI Redmi 1S phone it doesn't show the Toast message.
我已经看到了类似我的问题(像这样的很多问题 - 问题1 ,<一个href=\"http://stackoverflow.com/questions/5051687/broadcastreceiver-not-receiving-boot-completed\">Question 2 等)...但我没有得到任何解决这个问题。
I have already seen many questions similar to my issue (like these - Question 1, Question 2, etc.) ... But I haven't got any solution to this problem.
我的清单:
<?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>
MyReceiver.java
MyReceiver.java
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if ("android.intent.action.BOOT_COMPLETED".equalsIgnoreCase(intent.getAction())) {
Toast.makeText(context, "Boot Complete.", Toast.LENGTH_LONG).show();
}
}
}
我该如何解决呢?
How can I solve this?
推荐答案
这是你的错误的解决方案。
This is solution for your bug.
您需要做的是什么,你也需要提这个许可,您的意向过滤器。
What you need to do is that , you need to mention this permission also in your Intent-Filter.
<receiver android:name="com.example.demoapp.MyReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.REBOOT"/>
</intent-filter>
</receiver>
在这里,您需要做的一件事也。
Here you need to do one thing also.
进入设置 - Apps_open您的应用程序的信息,管理在未经许可的yourdevice
Go to "Settings-Apps_open your app info-Manage permisson" in yourdevice
下面检查所有的东西在这里。
Here check all things here.
由于某些设备将无法正常工作。
Ex.Red英里
Because for some devices it will not work. Ex.Red mi
试试这个!
这篇关于BOOT COMPLETE没有在Android平台(红米手机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!