Hi i write app that answers incoming call on press my overlayed button . this working perfect on android 4.0.3 - 4.3 but not on HTC sense 4 and HTC sense 5 . Anybody know how to bring in life this function for HTC sense ?
thanks a lot )
code i use in regular android for call acceptation : ///////////////////////////////////////////////////////////////////////////////////////////////
public static void answerIncomingCall(Context context) {
Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
i.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(i, null);
}
///////////////////////////////////////////////////////////////////////////////////////////////
Not worked for HTC sense. after i modified a bit and this worked on HTC openSens emulator but didnt work on real HTC sense 5 and 4 :
///////////////////////////////////////////////////////////////////////////////////////////////
public static void answerIncomingCallHTC(Context context) {
Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
i.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP ,KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(i, "android.permission.CALL_PRIVILEGED");
}
///////////////////////////////////////////////////////////////////////////////////////////////
i also tried to use open Sesne APi in HTCDev portal. And found two possible options but both didn't work also :(
1st :
PhoneCallUIService.PhoneCallUIState phone = new PhoneCallUIState(context);
phone.setCallState( PhoneCallUIService.PhoneCallUIState.CALL_STATE_OFFHOOK);
but got no class found exception ....
2nd: I tried to bind their open.phone service but i didn't succeed to do bound to the service
///////////////////////////////////////////////////////////////////////////////////////////////
public static void answerIncomingCallHTC(Context context) {
/// Defines callbacks for service binding, passed to bindService()
ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
// We've bound to LocalService, cast the IBinder and get LocalService instance
Log.d(TAG,"binding htc service");
mService = (PhoneCallUIService) service;
mBound = true;
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
mBound = false;
Log.d(TAG,"disconnected from htc service");
}
};
Intent intent = new Intent(context, PhoneCallUIService.class);
context.bindService(intent, mConnection, Context.MODE_PRIVATE);
if(mBound) {
Log.d(TAG,"before htc call");
mService.performAction(PhoneCallUIService.ACTION_ANSWER_CALL, 1, new Bundle());
Log.d(TAG,"after htc call");
}
else
Log.d(TAG,"the htc service not bounded");
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
It really eat my mind. Please help.
Tnx.