Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start activity from intentservice?

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

like image 349
ssb.serman Avatar asked May 20 '14 09:05

ssb.serman


People also ask

How do I start IntentService?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken text view, when user gets the data from intent service it will update.

How do I use IntentService?

Clients may use Context. startService(intent) to submit a request to start a Service (Intent). A worker thread is generated here, and all requests are handled by the worker thread, but only one request is processed at a time. To use IntentService, you must extend it and enforce the onHandleIntent (android.


1 Answers

Intent dialogIntent = new Intent(getBaseContext(), MainActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(dialogIntent);
like image 169
Long Rainbow Avatar answered Sep 27 '22 22:09

Long Rainbow