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.
thanks in advance