private void tryAndPrefillPhoneNumber() { if (checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { TelephonyManager manager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); mPhoneNumber.Text = manager.Line1Number; } else { ActivityCompat.requestPermissions(this, new string[] { Manifest.permission.READ_PHONE_STATE }, 0); } }
private void callButtonClicked() { string userName = mCallName.Text.ToString(); if (userName.Length == 0) { Toast.makeText(this, "Please enter a user to call", Toast.LENGTH_LONG).show(); return; } try { Call call = SinchServiceInterface.callUser(userName); string callId = call.CallId; Intent callScreen = new Intent(this, typeof(CallScreenActivity)); callScreen.putExtra(SinchService.CALL_ID, callId); startActivity(callScreen); } catch (MissingPermissionException e) { ActivityCompat.requestPermissions(this, new string[] { e.RequiredPermission }, 0); } }
private void requestPermissionForCamera() { ActivityCompat.requestPermissions(this, new string[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_REQUEST_CODE); }