When my service need to interact with the user it starts an activity:
Intent i = new Intent(context, Ringer_intent.class);
i.putExtra("PHONE_NUMBER", phone_number);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
// TODO: This prevents onDestroy --> why???
i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(i);
In order to make sure that Ringer_intent will not run twice I added
i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
And I also added to my activity
@Override
public void onNewIntent (Intent intent) {
}
I want my Ringer_intent activity to go away when it finishes. I do not want the user to be able to bring it back to the fg.
That the way it work w/o FLAG_ACTIVITY_SINGLE_TOP
But with FLAG_ACTIVITY_SINGLE_TOP my activity remains in the bg ...
I added the following:
@Override
public void onStop() { Log.i(LOG_TAG, "Ringer_intent.onStop()"); // For Debugging
super.onStop();
}
@Override
public void onDestroy() { Log.i(LOG_TAG, "Ringer_intent.onDestroy()"); // For Debugging
super.onDestroy();
Log.e(LOG_TAG, "Still not dead - kill it!");
// Bad idea - it kills my service as well !!!
// android.os.Process.killProcess(android.os.Process.myPid());
}
So I can see that Androids is calling both
But my activity is still there ...
Any idea?
Thanks
Note:
I tried to call finish() from onDestroy() - did not help