0

I'm having a requirement where i will registering few alarm manager to perform specific task and on onReceive() i'm doing the specific task.

As of now this is working only when the task is in background that is not killed.

I'm planning to open a application using package name when the application is not in background on onReceive(). As per my research, it is only possible to open activity from onReceive() but not the application using package name.

If possible could you please shed some light on how to proceed further?

Thank you

coders
  • 719
  • 1
  • 11
  • 35

2 Answers2

2

Yes, try this

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("package");
startActivity( LaunchIntent );

OR

startActivity(getPackageManager().getLaunchIntentForPackage("package"));
Rakesh
  • 756
  • 1
  • 9
  • 19
0

If it is your own app then you can use this

Intent intentone = new Intent(context.getApplicationContext(), "LauncherActivity");
intentone.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intentone);

This will work in my case. let me know if it does for you.

GvSharma
  • 2,632
  • 1
  • 24
  • 30