Android app right after boot

I made an Android app that starts right after the download is complete. It works in Android 2.3.3 and Android 3.1, but when I force close the application that runs in android 3.1 and I restart again, the application does not come after loading?

+6
source share
2 answers

when I force close the application that starts in android 3.1 and I reboot again, the application does not come after loading?

Right. In Android 3.1+, the following types of applications will not start automatically:

  • Recently Installed Applications
  • Applications that the user has "stopped."

These applications must first be started manually by the user (for example, run one of your actions) before they receive the Intents transfer again.

+2
source

I am doing this with this code and it works for me:

 public class AutoStarter extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { Intent serviceLauncher = new Intent(context, your.class); context.startService(serviceLauncher); } } } 

for testing you can use this in your cmd

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

+2
source

Source: https://habr.com/ru/post/913405/


All Articles