将呼出前等待用户输入 [英] Wait for user input before placing outgoing call

查看:105
本文介绍了将呼出前等待用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图拦截拨出电话给用户一个选项,以中止或继续通过对话的呼吁。

I am trying to intercept an outgoing call and give the user an option to abort or continue the call via a dialog.

第一步显然是写一个BroadcastReceiver该寄存器用于NEW_OUTGOING_CALL,我已经成功地完成。

The first step is obviously writing a BroadcastReceiver that registers for NEW_OUTGOING_CALL, which I have done successfully.

我也创建了一个基于对话框的主题,$ P $的活动psents用户与中止/继续按钮。当拨出电话放在我目前的code没有问题从广播接收器推出这一点。

I have also created an Activity based on the Dialog theme that presents the user with the Abort/Continue buttons. My current code has no problem launching this from the broadcast receiver when an outgoing call is placed.

我在哪里挣扎与控股调用动作,直到用户有机会作出回应。当你从一个BroadcastReceiver的方法的onReceive调用startActivity,这一呼吁立即返回,在我的情况下,意味着该呼叫经历,而对话正在presented。

Where I am struggling is with holding the call action until the user has a chance to respond. While you can call startActivity from the onReceive method of a BroadcastReceiver, that call returns immediately which, in my case, means that the call goes through while the dialog is being presented.

的<一个href=\"http://developer.android.com/reference/android/content/BroadcastReceiver.html#ReceiverLifecycle\"相对=nofollow> Android的接收器生命周期的信息对这个相当严格的拿,说:

The Android "Receiver Lifecycle" information has a fairly strict take on this, saying:

在特别的,你可能不会显示从内对话框或绑定到一个服务
  广播接收器。对于前者,你应该改用NotificationManager API。
  对于后者,你可以使用Context.startService()将命令发送到服务。

In particular, you may not show a dialog or bind to a service from within a BroadcastReceiver. For the former, you should instead use the NotificationManager API. For the latter, you can use Context.startService() to send a command to the service.

我明白阻塞以及显示在广播接收器的UI元素的一般不良。我也明白,Android是普遍异步,正因为如此,这是一个有点奇怪。然而,在这种情况下,我觉得这是合适的。通知将绝对不是解决我的问题。因此,我希望这里的聪明人在计算器可以发现,尽管谷歌的方式说,它不能做。

I understand the general badness of blocking as well as displaying UI elements in a broadcast receiver. I also understand that Android is generally asynchronous and, as such, this is a bit odd. However, in this case, I feel it is appropriate. A notification will most definitely not solve my problem. Thus I'm hoping that the smart people here at StackOverflow can find a way despite Google saying it cannot be done.

此外,谷歌语音似乎做了。

Also, Google Voice seems to do it.

不管怎样,我已经走遍计算器和净的答案,这个休息。虽然有大量的相关问题,我还没有找到一个完全抓住我的问题的性质,除了<一个href=\"http://stackoverflow.com/questions/2937216/how-can-i-display-a-dialog-box-for-making-a-choice-before-a-call-is-processed-in\">this 之一,这是死,但唯一的答案完全忽略了一点。

Anyway, I have scoured StackOverflow and the rest of the net for an answer to this. While there are a ton of related questions, I have yet to find one that fully captures the nature of my problem except for this one, which is dead-on, but the only answer completely missed the point.

这我已经考虑一种选择是中止原始呼叫,然后如果用户选择继续放置一个新的。我想我会以某种方式信号我的广播接收器不显示这种情况下的对话。这应该是可行的,但感觉过于复杂。

One option that I have considered is to abort the original call and then place a new one if the user chooses "continue". I assume I'll have to somehow signal my broadcast receiver not to show the dialog for this case. This should be doable, but it feels overly complicated.

感谢您事先的任何帮助。

Thanks in advance for any help.

推荐答案

我猜你可以使用呼叫意图过滤器来调用您的活动,如果用户要求..这将创建一个对话框,询问它仍将德,直到用户给出的输入。纠正我,如果我错了。

I guess you can use the call intent filters to invoke your activity if user requires .. that will create an asking dialog it will remain der until user gives an input. Correct me If I m wrong.

这篇关于将呼出前等待用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆