Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 安卓-如何使用Intent.ACTION\u呼叫激活呼叫紧急号码?_Java_Android - Fatal编程技术网

Java 安卓-如何使用Intent.ACTION\u呼叫激活呼叫紧急号码?

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

我正在开发一个Android应用程序,其中有紧急电话呼叫功能。我正在使用下面的呼叫代码:

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他询问的是紧急电话号码,不是任何具体的电话号码。……希望你能理解。。!!对不起。。。这个应用程序应该在全世界都能使用吗?也许这是一个定位电话的可能性,并获得与地理编码的国家。。。然后你记下这个国家的电话号码