android中的后台未接来电
如何从android应用程序拨打指定号码的未接电话。我已尝试此操作,但它将启动呼叫并等待呼叫终止。我想让电话响一次,然后停下来。请帮帮我android中的后台未接来电,android,performance,background,call,Android,Performance,Background,Call,如何从android应用程序拨打指定号码的未接电话。我已尝试此操作,但它将启动呼叫并等待呼叫终止。我想让电话响一次,然后停下来。请帮帮我 Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:123456789")); startActivity(callIntent); 从android应用程序拨打指定号码的未接电话 你可以做到,但不能保证(如果其他人立即接到电话)!计算一个
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
从android应用程序拨打指定号码的未接电话
你可以做到,但不能保证(如果其他人立即接到电话)!计算一个戒指需要多少时间。启动线程/计时器
,然后调用此方法以结束调用
private void mEndCall() {
try {
String serviceManagerName = "android.os.ServiceManager";
String serviceManagerNativeName = "android.os.ServiceManagerNative";
String telephonyName = "com.android.internal.telephony.ITelephony";
Class telephonyClass;
Class telephonyStubClass;
Class serviceManagerClass;
Class serviceManagerStubClass;
Class serviceManagerNativeClass;
Class serviceManagerNativeStubClass;
Method telephonyCall;
Method telephonyEndCall;
Method telephonyAnswerCall;
Method getDefault;
Method[] temps;
Constructor[] serviceManagerConstructor;
// Method getService;
Object telephonyObject;
Object serviceManagerObject;
telephonyClass = Class.forName(telephonyName);
telephonyStubClass = telephonyClass.getClasses()[0];
serviceManagerClass = Class.forName(serviceManagerName);
serviceManagerNativeClass = Class.forName(serviceManagerNativeName);
Method getService = // getDefaults[29];
serviceManagerClass.getMethod("getService", String.class);
Method tempInterfaceMethod = serviceManagerNativeClass.getMethod(
"asInterface", IBinder.class);
Binder tmpBinder = new Binder();
tmpBinder.attachInterface(null, "fake");
serviceManagerObject = tempInterfaceMethod.invoke(null, tmpBinder);
IBinder retbinder = (IBinder) getService.invoke(serviceManagerObject, "phone");
Method serviceMethod = telephonyStubClass.getMethod("asInterface", IBinder.class);
telephonyObject = serviceMethod.invoke(null, retbinder);
//telephonyCall = telephonyClass.getMethod("call", String.class);
telephonyEndCall = telephonyClass.getMethod("endCall");
//telephonyAnswerCall = telephonyClass.getMethod("answerRingingCall");
telephonyEndCall.invoke(telephonyObject);
} catch (Exception e) {
e.printStackTrace();
Log.e("error",
"FATAL ERROR: could not connect to telephony subsystem");
}
}
我认为这是不可能的,因为电话是由系统控制的,除非你有根控制,否则你可以在通话开始之前挂断电话,但不能在呼叫的中间挂断,因为通话时间变化很大。谢谢你的回答。