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.

4

1 回答 1

1

我想没有办法接收回调信息,因为ACTION_CALL不返回结果。即使您使用,您也可以看到输出不是文档中的任何内容startActivityForResult

于 2021-07-06T03:18:10.457 回答