<!--add permission to call outside --> <uses-permission android: Name= "Android.permission.CALL_PHONE" ></uses-permission> // Check if permissions are granted (Android6.0 runtime permissions) if (Contextcompat.checkselfpermission (mainactivity.this, manifest.permission.call_phone) != packagemanager.permission_granted) { // not authorized to apply for authorization if (Activitycompat.shouldshowrequestpermissionrationale ( Mainactivity.this, manifest.permission.call_phone)) { // return value:// If the app has previously requested this permission, the user rejects, this method will return true.// If the user previously denied permission, tick the "Don ' t ask again" option in the dialog box, Then this method will return false.// If the device policy prohibits the app from owning this permission, This method also returns false. // The popup needs to explain why this permission is required, and request authorization again toast.maketext (mainactivity.this, "please authorize! ", toast.length_long). Show (); // help jump to the app's settings screen and let users manually authorize intent intent = new intent (Settings.ACTION_APPLICATION_ Details_settings); uri uri = uri.fromparts ("Package", Getpackagename (), null); intent.setdata (URI); startactivity (Intent); }else{ // does not need to explain why this permission is required, direct request authorization activitycompat.requestpermissions (mainactivity.this, new string[]{manifest.permission.call_phone}, my_permissions_request_call_phone); } }else { // has been authorized to call // Start the call with intent Intent intent = new intent (Intent.action_call, uri.parse ("Tel:" + mobile)); StartActivity (intent);nbsp; }
This article is from the "Java" blog, so be sure to keep this source http://10594050.blog.51cto.com/10584050/1886211
Android make phone calls to Android call