Reputation: 4610
In my app, i have a widget. If user clicks on widget, I am opening SplashScreen using pending intent using below code.
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.widget_main_layout, pendingIntent);
This code works fine is app is not open and launch my splash screen.
However if app is already open and in background and if i click on widget then my SplashScreen not opening and instead only app comes to the froeground.
Could anyone let me know whats wrong with my code?
Upvotes: 5
Views: 2412
Reputation: 364
Use this code
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
Upvotes: 3
Reputation: 742
Set the flag of the intent you are passing to the pending Activity
to:
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
Upvotes: 2