5

I have Service implements IntentService and in the OnHandleIntent I want to start activity.

It does not work:

Intent dialogIntent = new Intent(this, typeof(Activity1));
dialogIntent.AddFlags(ActivityFlags.NewTask);
this.StartActivity(dialogIntent);

what else can I try?

upd: AddFlags(ActivityFlags.NewTask); it doesnt help

ssb.serman
  • 155
  • 1
  • 12
  • Did you find the soln to your question? If yes,then pls share.Also have a look at : " http://stackoverflow.com/questions/3606596/android-start-activity-from-service " – Basher51 Jul 21 '14 at 14:32

1 Answers1

9
Intent dialogIntent = new Intent(getBaseContext(), MainActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(dialogIntent);
Long Rainbow
  • 328
  • 3
  • 10
  • This code works. I wonder I used same except getApplicationContext() didn't work for me. If any one using application context please replace getBaseContext(). – Manju Feb 21 '19 at 08:02