Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Application Just After Boot

Tags:

java

android

I did a android application which launch just after boot finishes. It works in android 2.3.3 and Android 3.1 but when i force closed application which runs in android 3.1 and i reboot again the application doesn't come after boot ?

like image 442
Sarith Vasu Avatar asked Apr 17 '12 09:04

Sarith Vasu


2 Answers

when i force closed application which runs in android 3.1 and i reboot again the application doesn't come after boot ?

Correct. On Android 3.1+, the following types of applications will not run automatically:

  • Applications that are newly installed
  • Applications that the user has "force stopped"

Those applications must first manually be started by the user (e.g., launching one of your activities) before they will receive any broadcast Intents again.

like image 125
CommonsWare Avatar answered Oct 11 '22 17:10

CommonsWare


i do it 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

like image 41
Boe-Dev Avatar answered Oct 11 '22 18:10

Boe-Dev