firescript / nativescript-contacts

A nativescript module that gives access to the native contact directory.
MIT License
28 stars 32 forks source link

Android: Permission denial reading #14

Closed ghost closed 5 years ago

ghost commented 8 years ago

Hi, on my android testphone - were it worked until now - i get this exception:

Error: java.lang.SecurityException: Permission Denial: reading
com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/display_photo/2 from pid=26745, uid=10441 requires android.PERMISSION.READ_CONTACTS or grantUriPermission()

Permissions are not added to AndroidManifest.xml, if i add them by hand i still get the same error.

Also tried these suggstions: http://stackoverflow.com/questions/8104776/permission-read-contacts-does-not-seem-to-work - no success

Any hints?

ghost commented 8 years ago

Building with AndroidStudio gave a better hint @firescript:

Warning:The file: /home/mre/PROJECTS/test/node_modules/nativescript-contacts/platforms/android/AndroidManifest.xml is depricated, you can read more about what will be the expected plugin structure here: https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0

PeterStaev commented 8 years ago

Hey @einicher , although CLI throws this warning, it is a false one, as it was decided to keep AndroidManifest for plugins. You can read more here.

Have you installed the plugin using tns install nativescript-contacts? Also can you try to clean your android platforms and then building your project again:

tns platform clean android
tns deploy android
ghost commented 8 years ago

i did several times.

rm -rf node_modules platforms
tns platform add android
tns run android

same outcome, it shows me the contact selection dialog, but when i pick a contact i get the permission denied exception.

ghost commented 8 years ago

is it possible it has something to with

sudo npm install -g nativescript
npm install tns-core-modules@latest --save

i suddenly have to do this everytime i start a new project or else i get the error “app.js not found”

sitefinitysteve commented 8 years ago

It's this android 6? On Jul 8, 2016 9:45 AM, "Markus René Einicher" notifications@github.com wrote:

i did several times.

rm -rf node_modules platforms tns platform add android tns run android

same outcome, it shows me the contact selection dialog, but when i pick a contact i get the permission denied exception.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firescript/nativescript-contacts/issues/14#issuecomment-231363217, or mute the thread https://github.com/notifications/unsubscribe/ABeI6HrxMibBmEOZuo_tLTLwDxDiCck1ks5qTlSQgaJpZM4JH8xg .

ghost commented 8 years ago

@sitefinitysteve yes, android version 6.0.1

sitefinitysteve commented 8 years ago

Can you try this? https://www.npmjs.com/package/nativescript-permissions On Jul 8, 2016 10:04 AM, "Markus René Einicher" notifications@github.com wrote:

@sitefinitysteve https://github.com/sitefinitysteve yes, android version 6.0.1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firescript/nativescript-contacts/issues/14#issuecomment-231367824, or mute the thread https://github.com/notifications/unsubscribe/ABeI6K1Oi7WKJbrIdcCbK5sIR4BNu0P6ks5qTljdgaJpZM4JH8xg .

ghost commented 8 years ago

@sitefinitysteve “Woo Hoo, I have the power” it works. Very important contribution, I would have nver thought about that, I thought it asks by itself, like qr-plugin does. thx!!

sitefinitysteve commented 8 years ago

I'll see what i can do, or at least document it On Jul 8, 2016 10:23 AM, "Markus René Einicher" notifications@github.com wrote:

@sitefinitysteve https://github.com/sitefinitysteve “Woo Hoo, I have the power” it works. Very important contribution, I would have nver thought about that, I thought it asks by itself, like qr-plugin does. thx!!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firescript/nativescript-contacts/issues/14#issuecomment-231372924, or mute the thread https://github.com/notifications/unsubscribe/ABeI6E6ASiJi-dkyKNOFO63r12WL27Efks5qTl1kgaJpZM4JH8xg .

koganalon commented 7 years ago

You'll need a Runtime permission. 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.

jzgoda commented 5 years ago

Docs have been updated to avoid this issue.

hinalt commented 3 years ago

I still get this error. Can you please paste an working example to explain this?