0

I need to start my application on startup. I found this answer where a service is started on startup. I also found this thread where they use an intent-filter in order to receive the android.content.Intent.BOOT_COMPLETED_ACTION broadcasted on start up.

If I don't need to start a service, what is the best way for obtaining startup events of device?

Community
  • 1
  • 1
GVillani82
  • 17,196
  • 30
  • 105
  • 172

1 Answers1

1

Register the receiver using android.intent.action.BOOT_COMPLETED also add permission "android.permission.RECEIVE_BOOT_COMPLETED"

in the onRecieve function start your luncher actiivity

public void onReceive(Context context, Intent intent) {
            Intent i = new Intent(context, First.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(i);
        }
stinepike
  • 54,068
  • 14
  • 92
  • 112