Skip to content Skip to sidebar Skip to footer

Broadcastreceiver Is Not Started After Device Boot

After device reboot, I want to run my receiver so that the device can play audio when the device screen is turned on or turned off without setting them manually through the app. Mu

Solution 1:

Define your manifest something like this.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dev.hb.testing">

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <receiver android:name=".LockScreenReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            </intent-filter>
        </receiver>

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name=".WelcomeActivity" />
    </application>

</manifest>

Post a Comment for "Broadcastreceiver Is Not Started After Device Boot"