Reputation: 731
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
Upvotes: 0
Views: 897
Reputation: 2670
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.
Upvotes: 0
Reputation: 756
Yes, try this
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("package");
startActivity( LaunchIntent );
OR
startActivity(getPackageManager().getLaunchIntentForPackage("package"));
Upvotes: 2