//manitor tamas public class PhoneCallListener extends PhoneStateListener { private boolean onCall = false; @Override public void onCallStateChanged(int state, String incomingNumber) { switch (state) { case TelephonyManager.CALL_STATE_RINGING: // phone ringing... Toast.makeText(Page3Activity.this, incomingNumber + " tamas shoma", Toast.LENGTH_LONG).show(); break; case TelephonyManager.CALL_STATE_OFFHOOK: // one call exists that is dialing, active, or on hold //because user answers the incoming call onCall = true; Toast.makeText(Page3Activity.this, "dr hal tamas", Toast.LENGTH_LONG).show(); } break; case TelephonyManager.CALL_STATE_IDLE: // in initialization of the class and at the end of phone call } // detect flag from CALL_STATE_OFFHOOK if (onCall == true) { Toast.makeText(Page3Activity.this, "back be barname", Toast.LENGTH_LONG).show(); // restart our application Intent restart = getBaseContext().getPackageManager(). getLaunchIntentForPackage(getBaseContext().getPackageName()); restart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(restart); onCall = false; } break; default: break; } } }