Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

re-open background application via notification item

I got an app with tabs and a notification bar entry, when I send it to background (click on home button) and try to re-open the application via click on the notification bar, the app restarts (last selected tab is lost).

When I hold the home button if the application is in the background and select it from there or click the app's icon on the homescreen, the previous state is restored per default (the correct tab is selected)

IMO the intent of the notification is wrong, but I'm not sure how to fix it.

In short: How to get a background application back to foreground when I click the notification entry?

thx!

like image 457
user356764 Avatar asked Jun 02 '10 18:06

user356764


2 Answers

Put these two lines. This will resume currently paused activity:

notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
like image 198
santhosh Avatar answered Sep 28 '22 00:09

santhosh


Intent intent = new Intent(Application.getContext(), ActivityHome.class);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Application.getContext().startActivity(intent);
like image 39
Kevin Parker Avatar answered Sep 28 '22 02:09

Kevin Parker