本文介绍了如何通过编程方式断开来电的安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要断开通话特定时间进入的。
I want to disconnect incoming call for a particular time.
我怎样才能做到这一点是不可能?
How can i do this is it impossible ?
我搜索,我发现这是不可能的。请帮助我。
I searched and i find it is impossible. please help me.
public class Telephony3 extends Service
{
Context context;
public IBinder onBind(Intent intent)
{
return null;
}
public void onCreate()
{
super.onCreate();
try
{
StateListener phoneStateListener = new StateListener();
TelephonyManager telephonymanager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
telephonymanager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}catch(Exception e)
{
e.printStackTrace();
}
}
class StateListener extends PhoneStateListener{
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
switch(state){
case TelephonyManager.CALL_STATE_RINGING:
//Disconnect the call here...
try{
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class c = Class.forName(manager.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony telephony = (ITelephony)m.invoke(manager);
telephony.endCall();
}catch(Exception e){
Log.d("",e.getMessage());
}
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
case TelephonyManager.CALL_STATE_IDLE:
break;
}
}
};
public void onDestroy()
{
}
}
///////////////////////////////////////////
make another package com.android.internal.telephony and make one interface ITelephony
public interface ITelephony
{
boolean endCall();
void answerRingingCall();
void silenceRinger();
}
当我把这个仿真器从另一个呼叫正在发生的事情。任何事情错在这里请建议我。
and when i call this emulator from another the calling is happening. any thing wrong here please suggest me.
在此先感谢
推荐答案
您可以生成自己的活动,处理行动ACTION_ANSWER。
You can generate your own activity that handles action "ACTION_ANSWER".
注册您的应用程序组件为目的的处理程序。
Register your application component as a intent handler.
这篇关于如何通过编程方式断开来电的安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!