1

I'm making an app in which you can chat and call with other contacts. But in case of calling, I've designed the app in such a way that after typing the number and clicking on the call icon, it takes you to native calls app for calling and updates the call log in my current app.

For this process, this is the code I've written:

if (nativeCall(mobileNumber)) {
    Intent intent = new Intent(Intent.ACTION_CALL).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse("tel:" + mobileNumber));
    if (((BaseActivity) context).isNetworkOk()) {
        addToUserCallLogs(context, DateUtils.convertTimestampToDate(), contactUri, "Out", System.currentTimeMillis());
    }
    context.startActivity(intent);
    return true;
}

You can see that I'm putting mobile number into the intent and starting it. And I'm using addToUserCallLogs() function to show it in my app's call logs.

This works fine usually, but in the issue is in the following case. When the user has multiple calling applications(For eg, the user has installed application named SMARTalk. Now he has native caller app and SMARTalk app to call from), in that case the Android system gives options to chose from like this: Screenshot of that scenario

Now, if he choses from one of them, even in that case there is no issue. Say he didn't chose any of those and clicked on the other part of the screen. Then this options bar will be closed. Since all this is happening after starting the intent, this call will be added in the call logs of the app from the function addToUserCallLogs(). But I don't want the call to be shown in the call Logs because I haven't done any call.

But according to the code I've written, before starting the intent, I'm adding into my app's call logs database. Is there a way the information of whether the call has happened or not can be sent back from the system to the app?

Or a way to get these options to be shown manually from the app?

Please comment if you need any more explanation.

Light Yagami
  • 961
  • 1
  • 9
  • 29

1 Answers1

1

I guess no way to receive the callback information because ACTION_CALL does not return a result. You can see the output is nothing from docs even you use startActivityForResult

hientp
  • 634
  • 4
  • 11
  • Are there any other ways possible? like getting those app options from the app itself and then when user choses one of them, you can use that app to call? – Light Yagami Jul 06 '21 at 03:24
  • Did you try to read the call log of system https://stackoverflow.com/questions/6786666/how-do-i-access-call-log-for-android? I think you can use the call log to verify your action is executed or not – hientp Jul 06 '21 at 03:59
  • reading call log is of course a solution. But writing code for that, asking for permission, .... all this is a very big task. Instead of that if there is some callback, it would be much easier. I want some solution like that. – Light Yagami Jul 06 '21 at 05:46