I actually want to overlay default calling screen and handle everything on my activity. The problem I am facing is how can I get the caller number and if it is a contact stored in my phone from Telecom.Call object because that is the only available object in InCallService onCallAdded Method.
Thanks for your help in advance.
public MyConnectionService() {
}
@Override
public void onCallAdded(Call call) {
super.onCallAdded(call);
Log.d("Call","new call Added");
CallActivity.call=call;
startActivity(new Intent(this,CallActivity.class));
}
@Override
public void onCallRemoved(Call call) {
super.onCallRemoved(call);
Log.d("Call","Call Removed");
}
This is the activity to accept and reject calls. right now the screen show only 2 buttons to accept and reject the call and it is working fine, I need the contact details to show then on the screen as well.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call);
name=findViewById(R.id.name);
screenLock = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(
PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
screenLock.acquire();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
name.setText(call.getRemainingPostDialSequence()); //call.getDetails().getCallerDisplayName()
call.registerCallback(new Call.Callback() {
@Override
public void onCallDestroyed(Call call) {
super.onCallDestroyed(call);
CallActivity.this.finish();
}
@Override
public void onDetailsChanged(Call call, Call.Details details) {
super.onDetailsChanged(call, details);
Log.d("details",call.getRemainingPostDialSequence()+":"+details.getCallerDisplayName());
}
});
}