[英]How i do to my app asks to make and manage phone calls?
My app need the user accept's the "Allow to make and manage phone calls" Pop up. 我的应用程序需要用户接受的“允许拨打和管理电话”弹出窗口。 How i make these pop up in the first time the application starts?
我如何在应用程序首次启动时弹出这些窗口?
I already added the permission in the manifest : 我已经在清单中添加了权限:
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
But nothing from the pop up. 但是没有弹出。
From Android 6.0 you must to provide runtime permissions link . 从Android 6.0开始,您必须提供运行时权限链接 。
public boolean isPermissionGranted() {
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(android.Manifest.permission.CALL_PHONE)
== PackageManager.PERMISSION_GRANTED) {
Log.v("TAG","Permission is granted");
return true;
} else {
Log.v("TAG","Permission is revoked");
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, 1);
return false;
}
}
else { //permission is automatically granted on sdk<23 upon installation
Log.v("TAG","Permission is granted");
return true;
}
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case 1: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getApplicationContext(), "Permission granted", Toast.LENGTH_SHORT).show();
call_action();
} else {
Toast.makeText(getApplicationContext(), "Permission denied", Toast.LENGTH_SHORT).show();
}
return;
}
// other 'case' lines to check for other
// permissions this app might request
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.