I want to write a android application which can send sb a missed call. It means that application call to sb by about 5 second. I know that this code start calling.
private void call() {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
} catch (ActivityNotFoundException e) {
Log.e("helloandroid dialing example", "Call failed", e);
}
}
But I dont know how to stop it(after 5 second)?
Ps.This question have got mark -1 because question is stupid or my english is bad?
There is no direct way to do this because once you start the callIntent, the control will go to the calling application.
But there are workarounds to do this by getting the ITelephony
object of TelephonyManager
using java reflection.
TelephonyManager tm = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm);
}catch(Exception e){}
telephonyService.endCall();
source: call-control-in-android