I have a mainActivity
.
When starts, it starts a service and bonds it.
There is a timer which will send the mainActivity
(this) to back after X seconds, while the service keep running and listening, i use moveTaskToBack (true)
.
When the service listener triggered, the service starts the activity, but instead of the activity to be called through onResume()
(since it was sent to back) its called through onCreate()
, to call the activity currently i use :
Intent dialogIntent = new Intent(getBaseContext(), MainActivity.class);
dialogIntent.addFlags(Intent.FLAG_FROM_BACKGROUND);
getApplication().startActivity(dialogIntent);
Which explains why the activity is created all over again.
I tried using FLAG_ACTIVITY_REORDER_TO_FRONT
but got an exception.
add this attribute in activity of AndroidManifest.xml android:launchMode="singleInstance"
in AndroidManitest.xml
AndroidMenifest.xml
<application>
<activity
android:launchMode="singleInstance">
</activity>
</application>