Android 6.0 Broadcast Receiver don’t receive BOOT_COMPLETE

My receiver is not working with Android 6.0 Marshmallow.

I am sending a broadcast through adb shell, see below:

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED received if application was open, App say:Working!

But if the application was not open, it has not been returning anything.

My code is here;

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.berate.rebootreceiverfromb3r0">
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" android:protectionLevel="signature|development"></uses-permission>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>


        </activity>

        <receiver android:name="com.example.berate.rebootreceiverfromb3r0.Yakala_Receiver">
                <intent-filter>
                    <category android:name="android.intent.category.DEFAULT"></category>
                    <action android:name="android.intent.action.BOOT_COMPLETED" />
                    <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                </intent-filter>
            </receiver>
    </application>

</manifest>

Receiver.Java;

public class Yakala_Receiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context,"i got it ",Toast.LENGTH_SHORT).show();
    }
}

Edit: I have very interesting info, My code is working on samsung (Android 6.0) devices. But my (Android 6.0) devices not responding me

Answer

I fixed, some new android devices have security application by default. some times these apps lock your auto-start mode.

Leave a Reply

Your email address will not be published. Required fields are marked *