I have a media player app and I am trying to handle events such as when you receive a phone call. I can get it stopped properly and kill the service. Then I need to switch back to the main activity so when the user gets done with their phone call they can re-select a station to play. The problem I have is when I switch the activity with startActivity(intent) it gets shown in front of the phone dialer--this is not a good user experience. So how can I get my app reset back to the correct activity without it showing in front of another app?
private BroadcastReceiver phoneReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
//stop the play service
Intent stopPlayingService = new Intent(context, Play.class);
stopService(stopPlayingService);
//switch back to the main screen
Intent showMain = new Intent(context, MouseWorldRadioActivity.class);
showMain.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//showMain.addFlags(Intent.); not sure whats needed here
startActivity(showMain);
}
};