android.intent.action.BOOT_COMPLETED not working with nexus 4

时间:2015-10-18 14:17:16

标签: android android-intent

I want to use android.intent.action.BOOT_COMPLETED for starting my service at start but I am not receiving its broadcast in nexus 4. Its working fine with Samsung phones.

HashMap

Also I have given permissions

<receiver android:name=".BootReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
</receiver>

Receiver file:

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

I am not receiving BOOT_COMPLETED intent.

ITS WORKING FINE WITH SAMSUNG MODELS BUT NOT WORKING WITH NEXUS 4. I AM USING ANDROID STUDIO. PLEASE HELP.

2 个答案:

答案 0 :(得分:0)

这适用于我,onReceive

   String action = intent.getAction();

    if(action.equals(Intent.ACTION_BOOT_COMPLETED)){
    //do stuff
}

答案 1 :(得分:0)

如果用户至少运行一次您的应用,您将只接收BOOT_COMPLETED广播。这是Android 3.1以来的一项安全措施。

这不会影响系统应用程序,但我想你不会写一个......

这有帮助吗?

相关问题