Android广播接收器未触发

Android广播接收器未触发,android,android-emulator,broadcastreceiver,android-service,Android,Android Emulator,Broadcastreceiver,Android Service,与这个话题相关的问题很多。但我无法让它在emulator 5.0上的设备4.2.1上运行,它工作正常: 这是舱单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.bootService" android:versionCode="1" android:versionNa

与这个话题相关的问题很多。但我无法让它在emulator 5.0上的设备4.2.1上运行,它工作正常:

这是舱单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bootService"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <receiver
        android:name=".MyBroadcastReceiver"
        android:enabled="true"
        android:label="MyBroadcastReceiver" >
        <intent-filter android:priority="1001" >
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

    <activity
        android:name=".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>

    <service android:name=".PingService" >
    </service>
    <service android:name=".UpdateService" >
    </service>

    <receiver android:name=".OnBootReceiver" >
        <intent-filter android:priority="1001" >
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>
</application>
</manifest>
我看不出这个错误。有人知道吗? PS应用程序启动一次,因此:已覆盖


谢谢,

我花了很长时间才发现问题的关键在manifest.xml中

此处是使其运行的更改(仅接收器块):


重要的是

<category android:name="android.intent.category.DEFAULT" />


tag

BOOT_已完成这意味着,当您重新启动设备并准备好使用时。“我希望你能理解它的意思。”当然是穆塔扎侯赛因。上面的代码应该在移动设备完成引导后在sd卡上显示一个日志文件。但是它不工作。我刚刚发现在模拟器上它工作,在我的移动设备上没有。你的设备有哪些操作系统?
 <receiver
        android:name="com.example.bootService.MyBroadcastReceiver"
        android:exported="true"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_REPLACED" />

            <data
                android:path="com.example.bootService"
                android:scheme="package" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </receiver>
<category android:name="android.intent.category.DEFAULT" />