android - I can't show Manifest.permission.CALL_PHONE in runtime permission -
i'm implementing runtime permissions in app can't show permission call_phone. need show 2 permission, read_contact , call_phone. can show read_contact not call_phone permission.
i'm using avd emulator test it.
some apreciate!
this code:
callpesmission.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { requestcallphonepermission(); } }); contactpesmission.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { requestcontactspermission(); } }); private void requestcontactspermission() { string locationpermission = manifest.permission.read_contacts; int haspermission = contextcompat.checkselfpermission(getactivity(), locationpermission); string[] permissions = new string[] { locationpermission }; if (haspermission != packagemanager.permission_granted) { requestpermissions(permissions, request_contacts); } else { toast.maketext(getactivity(), "we have persmission", toast.length_short).show(); } } private void requestcallphonepermission() { string callpermission = manifest.permission.call_phone; int haspermission = contextcompat.checkselfpermission(getactivity(), callpermission); string[] permissions = new string[] { callpermission }; if (haspermission != packagemanager.permission_granted) { requestpermissions(permissions, request_call_phone); } else { toast.maketext(getactivity(), "we have persmission", toast.length_short).show(); } } @override public void onrequestpermissionsresult(int requestcode, string[] permissions, int[] grantresults) { switch (requestcode) { case request_contacts: if (grantresults[0] == packagemanager.permission_granted) { toast.maketext(getactivity(), "read_contacts granted", toast.length_short).show(); } else { toast.maketext(getactivity(), "read_contacts denied", toast.length_short).show(); } break; case request_call_phone: if (grantresults[0] == packagemanager.permission_granted) { toast.maketext(getactivity(), "call_phone granted", toast.length_short).show(); } else { toast.maketext(getactivity(), "call_phone denied", toast.length_short).show(); } break; default: super.onrequestpermissionsresult(requestcode, permissions, grantresults); } }
i see nothing wrong code right there,
confirm if present in manifest.xml.
dialog won't show if not present in manifest , might throw security exception if try use feature anyway
Comments
Post a Comment