I've a service
which starts a notification
with startForeground()
, I want the notification to launch an activity on click.
The acitivty
I want to launch defined as android:launchMode="singleTask"
and usually runs before the service starts.
Here is my pending intent
creation code :
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
When I click on the notification I get the following warning :
startActivity called from non-Activity context;
forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent........
I've also tried getting the activity with this
instead of getApplicationContext()
but got the same warning.
How should I make this right ?