This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Take photo and save path

 
Ruben Matt
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am trying to take a photo and then save its path.
I already take the photo but i cant save the path i dont know why. I wanted to try with the emulator to see the error but i cant take a picture with that.

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

}catch(Exception e){

}


Forcibly ignoring an exception is not a good idea. You should print the stack trace to to the logcat output so you'll know it if something goes wrong.

What does "i cant save the path" mean? Which parts of this code are or are not executing, what is the result of its running, and how is that different from what you were expecting?
 
Ruben Matt
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cant see the error because anytime i click take photo it says "The camera stopped working" so i dont know the what error it might be but im going to try again.
By path i mean mnt/sdcard/picture/ola.jpg
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so i dont know the what error it might be

Does that mean other parts of Android -besides your app- print nothing at all into the logcat? That would be very unusual, especially if something goes wrong.

You should print the stack trace to to the logcat output so you'll know it if something goes wrong.

That goes for the try/catch block in lines 21-31 as well, by the way.
 
Ruben Matt
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The logcat show this:



But i think this is because i cant try in the emulator.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your app have permission to use the camera? http://stackoverflow.com/questions/6886776/java-lang-runtimeexception-fail-to-connect-to-camera-service is the first result for "java.lang.RuntimeException: Fail to connect to camera service"
 
Ruben Matt
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not have that permission. i added that and tried:



The taking photo part works fine on my phone, the problem is that it doesnt save/show the path.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds as if the permission is still not present (or not recognized); try a clean build.

Is the onActivityResult method ever called? I would expect it to be called with a resultCode other than RESULT_OK if the camera can't be accessed for some reason. You may want to write the request and result codes to the logcat first thing in that method, before you do anything about it (and to write liberally to the logcat throughout the app in general - exception messages, intermediate values, etc.).
 
Ruben Matt
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'll try what you said, thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic