Guest User

Untitled

a guest
Dec 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public class StartBoot extends BroadcastReceiver {
  2. @Override
  3. public void onReceive(Context context, Intent intent) {
  4. if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
  5. Intent intent1 = new Intent(context,MyService.class);
  6. context.startService(intent1);
  7. }
  8. }
  9. }
  10.  
  11. <application
  12. android:allowBackup="true"
  13. android:icon="@mipmap/ic_launcher"
  14. android:label="@string/app_name"
  15. android:roundIcon="@mipmap/ic_launcher_round"
  16. android:supportsRtl="true"
  17. android:theme="@style/AppTheme">
  18.  
  19. <activity android:name=".MainActivity">
  20. <intent-filter>
  21. <action android:name="android.intent.action.MAIN" />
  22.  
  23. <category android:name="android.intent.category.LAUNCHER" />
  24. </intent-filter>
  25. </activity>
  26.  
  27. <receiver android:name=".StartBoot">
  28. <intent-filter>
  29. <action android:name="android.intent.action.BOOT_COMPLETED"/>
  30. <category android:name="android.intent.category.DEFAULT"/>
  31. </intent-filter>
  32. </receiver>
  33.  
  34. <service
  35. android:name=".MyService"
  36. android:enabled="true"
  37. android:exported="true"></service>
  38. </application>
  39.  
  40. 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