Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StartBoot extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
- Intent intent1 = new Intent(context,MyService.class);
- context.startService(intent1);
- }
- }
- }
- <application
- android:allowBackup="true"
- android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
- android:roundIcon="@mipmap/ic_launcher_round"
- 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=".StartBoot">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </receiver>
- <service
- android:name=".MyService"
- android:enabled="true"
- android:exported="true"></service>
- </application>
- W/BroadcastQueue: Permission Denial: receiving Intent { act=android.intent.action.BOOT_COMPLETED flg=0x9000010 (has extras) } to com.google.android.apps.docs/.app.NotificationChannelReceiver requires android.permission.RECEIVE_BOOT_COMPLETED due to sender null (uid 1000)
Add Comment
Please, Sign In to add comment