PHONE_CALL permission does not work in Dexter

I applied Dexter in my application. This works great for resolving CAMERA, EXTERNAL STORAGE and INTERNAL STORAGE. I want to call using PHONE_CALL using Dexter . When I call an intent for a phone call, for example:

Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + strNum)); startActivity(callIntent); 

then startActivity shows a warning Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityException less... (Ctrl+F1)

I don’t understand that I have Dexter , and why does startActivity want to get its own permission?

+5
source share
1 answer

For API 23+, you should check the resolution:

 if (mContext.checkSelfPermission(Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) { Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + strNum)); startActivity(callIntent): } 

Intent.ACTION_CALL intent , which requires permission, namely android.permission.CALL_PHONE . But for sdk> = 23 you need to check the runtime with Manifest.permission.CALL_PHONE . It is designed for targets of 23 and above.

If you reduce the target load below 23, you do not need it, and Intent.ACTION_CALL will work fine.

+2
source

Source: https://habr.com/ru/post/1262980/


All Articles