Java 安卓-如何使用Intent.ACTION\u呼叫激活呼叫紧急号码?
我正在开发一个Android应用程序,其中有紧急电话呼叫功能。我正在使用下面的呼叫代码:Java 安卓-如何使用Intent.ACTION\u呼叫激活呼叫紧急号码?,java,android,Java,Android,我正在开发一个Android应用程序,其中有紧急电话呼叫功能。我正在使用下面的呼叫代码: private void call(String pnum) { private TelephonyManager telephone; private PhoneListener phList; telephone = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); phList = new P
private void call(String pnum) {
private TelephonyManager telephone;
private PhoneListener phList;
telephone = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
phList = new PhoneListener(this);
telephone.listen(phList, PhoneStateListener.LISTEN_CALL_STATE);
Intent call = new Intent(Intent.ACTION_CALL);
call.setData(Uri.parse("tel:" + pnum));
call.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(call);
finish();
}
而PhoneListener
类如下所示:
public class PhoneListener extends PhoneStateListener {
boolean called = false;
TelephonyManager mTelMgr;
InitiateScreen m;
public PhoneListener(InitiateScreen activity) {
mTelMgr = (TelephonyManager) activity
.getSystemService(Context.TELEPHONY_SERVICE);
m = activity;
}
@Override
public void onCallStateChanged(int state, String inNum) {
super.onCallStateChanged(state, inNum);
// Don't fire before the call was made
if (state == TelephonyManager.CALL_STATE_OFFHOOK)
called = true;
// Call has ended -- now bring the activity back to front
if (called && state == TelephonyManager.CALL_STATE_IDLE) {
called = false;
mTelMgr.listen(this, PhoneStateListener.LISTEN_NONE);
}
}
}
当我使用
INTENT.ACTION\u CALL
时,调用应该自动发生。但对于显示紧急号码的拨号盘(操作\拨号
)。我已经用非紧急号码验证了相同的代码。电话自动接通。那么,Android不支持直接拨打紧急电话吗。我们不能调用操作。在Android中拨打紧急电话号码。请帮助我了解您的输入。在活动中调用此选项
Intent-Intent=newintent(Intent.ACTION_调用,Uri.parse(“tel:”+“911”);
星触觉(意向)代码>
将此权限添加到您的清单:
试试这个
private void phoneCall()
{
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+txtPhn.getText().toString().trim()));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(callIntent);
}
你明白我上面的代码吗?我特别询问紧急电话号码。@Mex他询问的是紧急电话号码,不是任何具体的电话号码。……希望你能理解。。!!对不起。。。这个应用程序应该在全世界都能使用吗?也许这是一个定位电话的可能性,并获得与地理编码的国家。。。然后你记下这个国家的电话号码