Attila Nyers
Attila Nyers

Reputation: 1193

REstart activity from Service

I can start activity from service but I cannot restart it, this flag only brings to front the existing activity:

myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

how could I restart (finish the old, start new)?

Upvotes: 2

Views: 2817

Answers (2)

Bostone
Bostone

Reputation: 37126

It's bit a trickery but what you can do is to add something like RESTART=true to the intent that calls the Activity. In activity's onResume you can do getIntent and see if that flag exists and if so call finish() and call activity anew

Upvotes: 1

Gligor
Gligor

Reputation: 2940

Try finishing the activity first by calling:

activity.finish();

then do a new intent to start the activity again:

myIntent = new Intent(context, activity.class);
startActivity(myIntent);

Upvotes: 1

Related Questions