• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Run Time app permission

 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am trying to make an app using view pager with two fragments one fragment for camera and second fragment for contact List which requires permissions for accessing contact lists and camera.When I am installing its apk My Application is crashing.There is some problem in fetching permission from the users kindly have a look at my code and error and please suggest a solution.I am sharing code for Contacts and camera fragment.I am requesting for permissions in there particular fragments.
This is Camera Fragment


This is my contacts Fragment

Error is
 
Bartender
Posts: 7493
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As the stack trace shows, the error occurs in ContactVM.setData(ContactVM.java:38) (which you didn't post). Apparently that code needs the contact permission and doesn't have it.
 
priyanshi bhardwaj
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks this problem is sorted but getting some other problem in camera fragment the app is launching I get the options for accessing contacts and external storage.but permission for camera is not asked at this time.But if I again open the app then permission for camera is asked.I mean to say all three permissions(Contacts,Camera,External Storage )is not asked at the same time.When my app opens Contacts Fragment is shown.And I am not getting any stack trace also.
 
Tim Moores
Bartender
Posts: 7493
171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check which permissions the app has. Sometimes reinstalling the app via USB removes them, but not always in my experience.
 
priyanshi bhardwaj
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Check which permissions the app has. Sometimes reinstalling the app via USB removes them, but not always in my experience.


In Manifest I have declared all the permissions it's just requestPermission method is getting called two times 1. In Contacts fragment(for contacts permission)   2. in Camera Fragment (for camera permission) so when the app in launching for the first time then Contacts Fragments get's opened so I think so app only asks for permissions required for contacts Fragments.But again when app is opened then it definitely asks for permission for camera also.How to fix this?
 
priyanshi bhardwaj
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just want all the three permissions(camera,contacts and external storage) are asked at the launching time of app.
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic