I have an activity which occurs when a call is received. However, it only works the first time a call is received. What's the best way to make it work for subsequent calls? Should I do something besides startActivity (i.e. is there something like bringActivityToForeground?) or do I need to end the activity when the call is dropped? How would I end an activity?
public class CallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
Intent myIntent = new Intent(context, MyActivity.class);
context.startActivity(myIntent);
} else if (TelephonyManager.EXTRA_STATE_IDLE.equals(state)) {
// TODO: remove the screen?
}
}
}