Get Selected Phone Number From Contacts List Without Read_contacts Permission
Solution 1:
You don't need READ_CONTACTS actually.
Note: Before Android 2.3 (API level 9), performing a query on the Contacts Provider (like the one shown above) requires that your app declare the READ_CONTACTS permission (see Security and Permissions). However, beginning with Android 2.3, the Contacts/People app grants your app a temporary permission to read from the Contacts Provider when it returns you a result. The temporary permission applies only to the specific contact requested, so you cannot query a contact other than the one specified by the intent's Uri, unless you do declare the READ_CONTACTS permission.
Source: http://developer.android.com/training/basics/intents/result.html
Solution 2:
you SHOULDN'T need READ_CONTACTS actually. @Tony Chu is right, the documentation says:
Note: Before Android 2.3 (API level 9), performing a query on the Contacts Provider (like the one shown above) requires that your app declare the READ_CONTACTS permission (see Security and Permissions). However, beginning with Android 2.3, the Contacts/People app grants your app a temporary permission to read from the Contacts Provider when it returns you a result. The temporary permission applies only to the specific contact requested, so you cannot query a contact other than the one specified by the intent's Uri, unless you do declare the READ_CONTACTS permission. (Source)
HOWEVER, I've noticed that some phones may require it nonetheless (xperia devices in my experience and also HTC ones according to @AVirvara).
Sorry but it seems like you won't have any alternative.
Solution 3:
You can not access Android contacts dababase without giving READ_CONTACTS permission in your manifest file.
The Android mobile OS uses a permission system to help ensure that apps behave appropriately. The system allows apps to request access to features on the device that can use power, access sensitive data, and incur charges.
Solution 4:
Yous should write permission in manifest file then u only able to read contact from file.
Solution 5:
with or without placing the permission in your manifest, You will need to request that permission from the User on-the-fly.
if( getApplicationContext().checkSelfPermission( Manifest.permission.READ_CONTACTS ) != PackageManager.PERMISSION_GRANTED )
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.READ_CONTACTS}, resultValue);
only then after the approval you will be able to query the contacts phone number/name etc.
Post a Comment for "Get Selected Phone Number From Contacts List Without Read_contacts Permission"