Call 911 in Android

前端 未结 3 1707
名媛妹妹
名媛妹妹 2021-01-02 04:19

I want to call Emergency number using Android SDK.

I am using following code to call the number (911). This code works fine for all the numbers except 911 (Emergency

3条回答
  •  心在旅途
    2021-01-02 04:36

    The code provided should already work for this, but you need the CALL_PHONE and CALL_PRIVILEGED permission to dial emergency numbers without showing the dial-pad.

    Android Reference - Manifest Permission CALL_PRIVILEGED

    Once that is added to the manifest, you should be able to use the same code using the ACTION_CALL instead to direct dial:

    Uri callUri = Uri.parse("tel://911");
    Intent callIntent = new Intent(Intent.ACTION_CALL,callUri);
    callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    startActivity(callIntent);
    

提交回复
热议问题