如何直接在Android的拨打电话 [英] How to Make a Call directly in Android
问题描述
我知道这是很简单的事情,但我遇到一个很奇怪的问题。我打电话给警察处于危险状况,只需按一个按钮就。所以,我已经使用下列code调用。
I know it was very simple to do it but I come across a very strange issue. I have to call Police in danger Situation by just tapping a button. So I have used following code to call.
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:100"));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(callIntent);
新增 CALL_PHONE
许可的AndroidManifest.xml
。问题是,它是在拨号盘开100,但不能直接拨打电话。我想,当用户点击按钮立即发生。
Added CALL_PHONE
permission in AndroidManifest.xml
. The Issue is that it is opening the 100 on Dial Pad but not making call directly. I want that to happen immediately when user clicks on the button.
当我试图把+91 100之前,它会自动呼叫的号码,但为什么加上需要这样的数字。所以有人帮助我如何解决这个问题
When I tried to to put +91 before 100 it is calling the number automatically but why plus is required for such numbers. So Someone help me how to solve this issue
推荐答案
从文件 ACTION_CALL
:
请注意:会有限制哪些应用程序可以发起呼叫;大多数应用程序应该使用ACTION_DIAL。
Note: there will be restrictions on which applications can initiate a call; most applications should use the ACTION_DIAL.
注:本意向书不能用来拨打紧急电话号码。应用程序可以拨打然而,使用ACTION_DIAL紧急号码。
Note: this Intent cannot be used to call emergency numbers. Applications can dial emergency numbers using ACTION_DIAL, however.
这么看来这种行为是故意的。
So it seems this behavior is on purpose.
这篇关于如何直接在Android的拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!