1

At the moment my app has a service running which is fired every hour. This pulls any photos thats have been taken since last time it was open and uploads then to the server. This is done using the system content provider

Now what I want to do is send an intent to open the camera app, I am doing this like so...

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);

What I would like to happen is when the focus comes back to my app (after the user has taken a picture), I can open the service and that takes care of the photo.

However it seems like the photo is never added to the content provider. The service opens it and the cursos has a count of 0. Is there anything i can do so the system adds the photo to the content provider or do I need to handle this myself?

Edit

So I figure there no intents I can use to get it to save to the system. So it would seem my options are either

contentResolver.insert()

or

MediaStore.Images.Mediea.insertImage()

What is the difference between these 2 methods?

Edit

So I am starting to think google are clueless with there implementation of this feature. Take this link

http://developer.android.com/guide/topics/media/camera.html#intent-receive

You pass in the Uri and when it returns to your app it gives you the uri you gave it. If you did not specify a uri it doesn't return one. What is the point in that? Why would I want data I already have? Surely it would make sense the other way around. Or even just giving you basic data you need such as name, path, mimetype. Would that be too difficult?

jiduvah
  • 5,108
  • 6
  • 39
  • 55

1 Answers1

0

Notify MediaScanner, when the scan is complete your photo will be added to the system database.

Teodor
  • 300
  • 1
  • 13
  • I had no idea about MediaScanner. Thanks. I will test it and let you knw – jiduvah Nov 06 '12 at 14:54
  • http://stackoverflow.com/q/9414955/1541073 class provided in question will do the trick. – Teodor Nov 06 '12 at 14:58
  • I am thinking its not the best solution, I don't want to scan the whole disk. I just want to insert a photo. – jiduvah Nov 06 '12 at 15:14
  • That's why I gave you the link. You can scan only specific path. – Teodor Nov 06 '12 at 15:55
  • Then go with the other way, MediaStore.Extra_output – Teodor Nov 06 '12 at 17:02
  • yup it looks like I have to. Its seems like there is all kinds of unnecessary shit I need to do. I don't understand why it doesn't add it to a contentprovider automatically. All I want to do it take a picture and access it via countent provider. Exactly what I do when other apps take photos. The only difference is I send to the intent to the app rather than android itself – jiduvah Nov 06 '12 at 17:09