0

could you please explain me why i can't start my activity from broadcast reciever with 5 sec. delay in this way.

 Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                context.startActivity(i);


            },5000);



  Handler handler = new Handler();
   hanlder.postDelay(new Runnable(){
       @Override
            public void run() {
                context.startActivity(i);


            },5000);
         }

And if you have any suggestions how to delay activity, I'll be very grateful for advice.

Nick Kyrpenko
  • 69
  • 1
  • 9
  • If this is truly from an `ACTION_BOOT_COMPLETED` receiver, you cannot reliably do anything in the background from a manifest-registered receiver, as your process may be terminated at any point after `onReceive()` returns. If you want to show UI when the phone boots, build a home screen. – CommonsWare Feb 02 '18 at 19:01
  • I want to prevent closing my application by another custom or system app at the boot time – Nick Kyrpenko Feb 02 '18 at 19:12
  • Fortunately, that is not possible, for obvious privacy and security reasons. – CommonsWare Feb 02 '18 at 19:17
  • why?I guess i don't do nothing crimminal This is my AndroidMinifest.xml :https://pastebin.com/2ThuYgMt – Nick Kyrpenko Feb 02 '18 at 19:24
  • This my BroadcastReciever: https://pastebin.com/v4WZnRAV – Nick Kyrpenko Feb 02 '18 at 19:24

0 Answers0