Here is My Manifest File :
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name = "android.permission.READ_PHONE_STATE"/>
Here is my Java Code :
switch (state){
case TelephonyManager.CALL_STATE_RINGING:
Toast.makeText(getApplicationContext(),"Ringing....",Toast.LENGTH_LONG).show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Toast.makeText(getApplicationContext(),"onCall....",Toast.LENGTH_LONG).show();
onCall= true;
break;
case TelephonyManager.CALL_STATE_IDLE:
if(onCall == true){
Toast.makeText(getApplicationContext(),"Restarting app",Toast.LENGTH_LONG).show();
//restarting application
Intent restart = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
restart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(restart);
onCall= false;
}
break;
default:
break;
}
How to identify when someone picks our call and how to do it?