Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
引导完成在Android中不起作用(Redmi)_Android_Broadcastreceiver_Bootcompleted - Fatal编程技术网

引导完成在Android中不起作用(Redmi)

引导完成在Android中不起作用(Redmi),android,broadcastreceiver,bootcompleted,Android,Broadcastreceiver,Bootcompleted,我目前正在开发一个应用程序,其中包括Boot_完整的广播接收器概念。我已经在我的摩托罗拉Moto G手机上测试了这个应用程序。该应用程序运行良好,并显示Toast消息。但当我在小米红米1S手机上测试这款应用时,它不会显示祝酒词 我已经看到许多与我的问题类似的问题(如-,等等)。。。但是我还没有解决这个问题的办法 我的舱单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas

我目前正在开发一个应用程序,其中包括Boot_完整的广播接收器概念。我已经在我的摩托罗拉Moto G手机上测试了这个应用程序。该应用程序运行良好,并显示Toast消息。但当我在小米红米1S手机上测试这款应用时,它不会显示祝酒词

我已经看到许多与我的问题类似的问题(如-,等等)。。。但是我还没有解决这个问题的办法

我的舱单:

<?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>

如何解决此问题?

如果XIOMI设备需要手动设置权限,我认为您可以通过在“自动启动管理”列表中添加应用程序来解决此问题,该列表作为默认安全应用程序提供。

转到管理应用程序权限

从应用中选择你的应用

切换“自动启动”


完成

尝试从广播接收器中删除if条件

public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, "Boot Complete.", Toast.LENGTH_LONG).show();
}
}

这是您的bug的解决方案

您需要做的是,您还需要在您的意图过滤器中提及此权限

               <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>

在这里,你还需要做一件事

转到设备中的“设置-应用程序\打开应用程序信息管理权限”

这里,检查所有东西

因为对于某些设备,它无法工作。 例如,红色米


试试这个

你的包裹名是什么??源MyReceiver包名??“com.example.demoapp”是我的包名@kalyanpvsFacing与Xiaomi Redmi 1s存在相同问题。然后在清单中更改它,如package=“com.example.demoapp”,并且is Myreceiver是类路径是“com.example.demoapp.Myreceiver”?我更改了它,但不起作用@kalyanpvsHow是否将我的应用添加到“自动启动管理”列表中@USER3188965这是我的Redmi 1s问题的解决方案。谢谢Jay提供的信息。添加对我的Redmi 1s没有帮助。它只在MIUI提供的安全应用程序的自动重启应用程序列表中添加了我的应用程序后才起作用。它在我的小米Note 10 lite中不起作用
               <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>