• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Run Time app permission

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • 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
 
Saloon Keeper
Posts: 5573
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • 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: 117
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Posts: 5573
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • 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: 117
  • Mark post as helpful
  • send pies
  • 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: 117
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!