[英]i want to make call on an emergency number by pressing the button in my mobile app with help of ACTION_CALL but i didn't. why?
i want to make call on an emergency number by pressing the button in my mobile app with help of ACTION_CALL but i didn't.我想在 ACTION_CALL 的帮助下按下我的移动应用程序中的按钮来拨打紧急号码,但我没有。 why?
为什么?
I implemented CALL_PHONE permission in my manifest file.我在清单文件中实现了 CALL_PHONE 权限。
<uses-permission android:name="android.permission.CALL_PHONE"/>
and this is my java code to call.这是我要调用的 java 代码。
public void makeCall(View v){
if (ActivityCompat.checkSelfPermission(this,Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED){
Toast.makeText(getApplicationContext(), "making call", Toast.LENGTH_LONG).show();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_NO_USER_ACTION);
callIntent.setData(Uri.parse("tel:108"));
startActivity(callIntent);
}else{
Toast.makeText(getApplicationContext(), "making call is not possible", Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.CALL_PHONE},MY_PERMISSIONS_REQUEST_CALL_PHONE);
}
}
this code takes me onto default dialer of mobile.此代码将我带到手机的默认拨号器。
How can i call on an emergency number directly by my app without reaching on default dialer?如何在不使用默认拨号器的情况下直接通过我的应用拨打紧急号码?
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+123));//change the number
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CALL_PHONE},12);
}else{
startActivity(callIntent);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.