Can we get Call details like caller number and contact details from InCallService or Telecom.Call?
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());
}
});
}
android in-call
add a comment |
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());
}
});
}
android in-call
add a comment |
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());
}
});
}
android in-call
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());
}
});
}
android in-call
android in-call
asked Nov 28 '18 at 12:21
Farhan AhmedFarhan Ahmed
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You have two options.
asking the user to make your app the default Phone app (basically your app will be the new
InCallService
/InCallUI
that you'd need to implement), see: https://developer.android.com/reference/android/telecom/InCallServiceimplementing a
PhoneStateListener
to detect to phone state changes (idle/ringing/offhook) and displaying your UI above the default InCallUI when appropriate, see: https://developer.android.com/reference/android/telephony/PhoneStateListener and Add PhoneStateListener
Thanks for your reply, really helped in getting caller number. I used onCallStateChanged(int state, String incomingNumber) but I am unable to get the number/contact for outgoing calls now. Can you help me with that?
– Farhan Ahmed
Nov 29 '18 at 5:44
see this: stackoverflow.com/questions/6611197/…
– marmor
Nov 29 '18 at 9:12
1
@Override public void onReceive(final Context context, Intent intent) { CallActivity.number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } This is what I did and finally I am getting the number. Thanks marmor
– Farhan Ahmed
Nov 29 '18 at 11:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53519369%2fcan-we-get-call-details-like-caller-number-and-contact-details-from-incallservic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have two options.
asking the user to make your app the default Phone app (basically your app will be the new
InCallService
/InCallUI
that you'd need to implement), see: https://developer.android.com/reference/android/telecom/InCallServiceimplementing a
PhoneStateListener
to detect to phone state changes (idle/ringing/offhook) and displaying your UI above the default InCallUI when appropriate, see: https://developer.android.com/reference/android/telephony/PhoneStateListener and Add PhoneStateListener
Thanks for your reply, really helped in getting caller number. I used onCallStateChanged(int state, String incomingNumber) but I am unable to get the number/contact for outgoing calls now. Can you help me with that?
– Farhan Ahmed
Nov 29 '18 at 5:44
see this: stackoverflow.com/questions/6611197/…
– marmor
Nov 29 '18 at 9:12
1
@Override public void onReceive(final Context context, Intent intent) { CallActivity.number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } This is what I did and finally I am getting the number. Thanks marmor
– Farhan Ahmed
Nov 29 '18 at 11:25
add a comment |
You have two options.
asking the user to make your app the default Phone app (basically your app will be the new
InCallService
/InCallUI
that you'd need to implement), see: https://developer.android.com/reference/android/telecom/InCallServiceimplementing a
PhoneStateListener
to detect to phone state changes (idle/ringing/offhook) and displaying your UI above the default InCallUI when appropriate, see: https://developer.android.com/reference/android/telephony/PhoneStateListener and Add PhoneStateListener
Thanks for your reply, really helped in getting caller number. I used onCallStateChanged(int state, String incomingNumber) but I am unable to get the number/contact for outgoing calls now. Can you help me with that?
– Farhan Ahmed
Nov 29 '18 at 5:44
see this: stackoverflow.com/questions/6611197/…
– marmor
Nov 29 '18 at 9:12
1
@Override public void onReceive(final Context context, Intent intent) { CallActivity.number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } This is what I did and finally I am getting the number. Thanks marmor
– Farhan Ahmed
Nov 29 '18 at 11:25
add a comment |
You have two options.
asking the user to make your app the default Phone app (basically your app will be the new
InCallService
/InCallUI
that you'd need to implement), see: https://developer.android.com/reference/android/telecom/InCallServiceimplementing a
PhoneStateListener
to detect to phone state changes (idle/ringing/offhook) and displaying your UI above the default InCallUI when appropriate, see: https://developer.android.com/reference/android/telephony/PhoneStateListener and Add PhoneStateListener
You have two options.
asking the user to make your app the default Phone app (basically your app will be the new
InCallService
/InCallUI
that you'd need to implement), see: https://developer.android.com/reference/android/telecom/InCallServiceimplementing a
PhoneStateListener
to detect to phone state changes (idle/ringing/offhook) and displaying your UI above the default InCallUI when appropriate, see: https://developer.android.com/reference/android/telephony/PhoneStateListener and Add PhoneStateListener
answered Nov 28 '18 at 14:07
marmormarmor
19.5k884128
19.5k884128
Thanks for your reply, really helped in getting caller number. I used onCallStateChanged(int state, String incomingNumber) but I am unable to get the number/contact for outgoing calls now. Can you help me with that?
– Farhan Ahmed
Nov 29 '18 at 5:44
see this: stackoverflow.com/questions/6611197/…
– marmor
Nov 29 '18 at 9:12
1
@Override public void onReceive(final Context context, Intent intent) { CallActivity.number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } This is what I did and finally I am getting the number. Thanks marmor
– Farhan Ahmed
Nov 29 '18 at 11:25
add a comment |
Thanks for your reply, really helped in getting caller number. I used onCallStateChanged(int state, String incomingNumber) but I am unable to get the number/contact for outgoing calls now. Can you help me with that?
– Farhan Ahmed
Nov 29 '18 at 5:44
see this: stackoverflow.com/questions/6611197/…
– marmor
Nov 29 '18 at 9:12
1
@Override public void onReceive(final Context context, Intent intent) { CallActivity.number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } This is what I did and finally I am getting the number. Thanks marmor
– Farhan Ahmed
Nov 29 '18 at 11:25
Thanks for your reply, really helped in getting caller number. I used onCallStateChanged(int state, String incomingNumber) but I am unable to get the number/contact for outgoing calls now. Can you help me with that?
– Farhan Ahmed
Nov 29 '18 at 5:44
Thanks for your reply, really helped in getting caller number. I used onCallStateChanged(int state, String incomingNumber) but I am unable to get the number/contact for outgoing calls now. Can you help me with that?
– Farhan Ahmed
Nov 29 '18 at 5:44
see this: stackoverflow.com/questions/6611197/…
– marmor
Nov 29 '18 at 9:12
see this: stackoverflow.com/questions/6611197/…
– marmor
Nov 29 '18 at 9:12
1
1
@Override public void onReceive(final Context context, Intent intent) { CallActivity.number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } This is what I did and finally I am getting the number. Thanks marmor
– Farhan Ahmed
Nov 29 '18 at 11:25
@Override public void onReceive(final Context context, Intent intent) { CallActivity.number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } This is what I did and finally I am getting the number. Thanks marmor
– Farhan Ahmed
Nov 29 '18 at 11:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53519369%2fcan-we-get-call-details-like-caller-number-and-contact-details-from-incallservic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown