Sorry, I thought you saved one file to SD card by yourself but the file was media-scanned.
Things seems to be that you can get the bitmap from Camera but camera always save a copy into MediaStore. So you can see it in Gallery. I think there are two options: 1. Leave it alone. Since user capture the image using Camera, it is normal that the user can see it in Gallery. 2. I don't know how you implement _helper.deleteFiles(). Seems you have got the file path. You can try to use ContentResolver.delete(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, ...) to match and delete that record. Or you can query that record firstly then delete it using ContentResolver.delete(). On Tue, Apr 26, 2011 at 9:39 PM, Fina Perez <[email protected]> wrote: > Sorry for my really bad explanation, this problem drives me up the > wall... > > The situation is: > > from my app, I call Camera application, take a picture and go back to > my app. So, I do as follows: > > Intent camara = new > Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); > startActivityForResult(camara, CAMERA_PIC_REQUEST); > > Then, when I go back to my app, I handle the picture: > > protected void onActivityResult(int requestCode, int > resultCode, Intent data) { > if(requestCode == CAMERA_PIC_REQUEST) { > if(data == null) { > //do some stuff, > }else { > //get the bitmap > Bitmap myPicture = > (Bitmap)data.getExtras().get("data"); > > //save the bitmap > _pictures.add(myPicture); > > //and delete the picture from the > device > _helper.deleteFiles(); //this method, delete > the picture from the > sdcard > _helper = null; > > //in the gallery app, remains a > "picture" or thumbnail of the picture I've just taken, and > //here is where I have the problem, > because I cannot find a good solution to delete or clean > //the gallery. > > //I'll write my options below > > } > } > } > > > So, the things I tried are: > > 1) //This option doesn't work on some devices like the galaxy S (I > don't know why) > Uri uri = data.getData(); > getContentResolver().delete(uri, null, > null); > > 2) //This option works but launch the mediaScanner, and makes some > devices (like the galaxy S) really slow, so I'm trying > // to avoid this option: > sendBroadcast(new > Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + > Environment.getExternalStorageDirectory()))); > > 3) //This option tries to change the directory, but I think I'm > missing something, because the pictures are displayed in the gallery > app (and i don't want that) > //Where I launch the camera, I wrote: > > _path = Environment.getExternalStorageDirectory()+"/ > tempPictures/.nomedia"; > File file = new File(_path); > Uri uri = Uri.fromFile( file ); > Intent camara = new > Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); > camara.putExtra( MediaStore.EXTRA_OUTPUT, uri); > startActivityForResult(camara, CAMERA_PIC_REQUEST); > > 4) I tried to do what Liang proposed: "You can let camera return > bitmap data, then you handle the data by yourself. There is no file > saved this way." I did using Intent.#setType(String) but It never > worked. > > So, what am I missing? what am I doing wrong? > > Thanks for reading and helping! > > On Apr 26, 2:26 pm, Liang Wang <[email protected]> wrote: > > 1. For first option, if you provide more details , that will be helpful. > > > > 2. For second option. It will be better if you store the file into a > > directory in sd card instead of root directory. For example: > > in /sdcard/TempDir/, there are two files > > .nomedia (empty file, to stop media scanner) > > youfile.jpg (you specified file) > > > > 3. Maybe camera saved another image that can be seen in gallery beside > > saving to your file. If this is true, you can delete your file safely > with > > .nomedia protection. It will not influence the gallery. > > > > Hope these are helpful. But camera implementation of different phones may > > differ. I'm not sure if above can work. > > > > On Tue, Apr 26, 2011 at 6:42 PM, Fina Perez <[email protected]> > wrote: > > > > > Hi, > > > that's what I'm using now, because I cannot make the first option > > > runs. But I'm having problems with the second option too.. > > > > > _path = Environment.getExternalStorageDirectory() + ".nomedia"; > > > Intent camara = new > > > Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); > > > File file = new File(_path); > > > Uri uri = Uri.fromFile(file); > > > camara.putExtra(MediaStore.EXTRA_OUTPUT, uri); > > > startActivityForResult(camara, CAMERA_PIC_REQUEST); > > > > > this is the code I'm using to "hide" the pictures I take with the > > > camera, but they still appear in the Gallery app, which is what I want > > > to avoid. And I want to avoid the mediascanner runs too... > > > > > Please, please, help! > > > > > On Apr 26, 10:28 am, Liang Wang <[email protected]> wrote: > > > > Hi Fina, > > > > > > I think below code will work: > > > > Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); > > > > startActivityForResult(intent, ...); > > > > > > Then you can handle the bitmap in onActivityResult(). > > > > > > The code you mentioned is from android built-in Camera application. > There > > > > you can see how camera app give result to you. From that you can get > how > > > to > > > > handle the result. > > > > > > On Tue, Apr 26, 2011 at 3:51 PM, Fina Perez <[email protected]> > > > wrote: > > > > > Hi Liang! > > > > > thanks a lot for your answer. > > > > > > > I was trying the first option but I'm having problems to tell the > > > > > camera that I want a bitmap. I tryed to use the method > > > > > "Inteng.#setType(String)" but I got an exception And I don't know > > > > > where the code you wrote comes from, I mean Is that the way to ask > for > > > > > a bitmap object as result? I thought it was more "intuitive" hehehe > > > > > > > On Apr 22, 11:56 am, Liang Wang <[email protected]> wrote: > > > > > > 1. You can let camera return bitmap data, then you handle the > data by > > > > > > yourself. There is no file saved this way. > > > > > > > > 2. If you let camera save the image to file in a specified > > > > > directory(through > > > > > > provider), making a empty file named .nomedia in that directory > can > > > > > prevent > > > > > > mediascanner from scanning it. This way this image will not > appear in > > > > > > gallery. > > > > > > > > See the code below in Camera: > > > > > > if (mSaveUri != null) { > > > > > > OutputStream outputStream = null; > > > > > > try { > > > > > > outputStream = > > > > > > mContentResolver.openOutputStream(mSaveUri); > > > > > > outputStream.write(data); > > > > > > outputStream.close(); > > > > > > > > setResult(RESULT_OK); > > > > > > finish(); > > > > > > } catch (IOException ex) { > > > > > > // ignore exception > > > > > > } finally { > > > > > > Util.closeSilently(outputStream); > > > > > > } > > > > > > } else { > > > > > > Bitmap bitmap = createCaptureBitmap(data); > > > > > > setResult(RESULT_OK, > > > > > > new > Intent("inline-data").putExtra("data", > > > > > bitmap)); > > > > > > finish(); > > > > > > } > > > > > > > > On Fri, Apr 22, 2011 at 4:51 PM, Fina Perez < > [email protected]> > > > > > wrote: > > > > > > > Hi! > > > > > > > > > I answer myself: > > > > > > > > > maybe is not the best solution but after deleting the file, > this is > > > > > > > what I do: > > > > > > > > > sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, > > > > > > > Uri.parse("file://" + > Environment.getExternalStorageDirectory()))); > > > > > > > > > we need to add this to the manifest: > > > > > > > <intent-filter> > > > > > > > <action android:name="android.intent.action.MEDIA_MOUNTED" /> > > > > > > > <data android:scheme="file" /> > > > > > > > </intent-filter> > > > > > > > > > (I found the solution here: > > > > >http://stackoverflow.com/questions/4430888/android-file-delete-leaves. > > > > > .. > > > > > > > ) > > > > > > > > > On Apr 21, 11:32 am, Fina Perez <[email protected]> > wrote: > > > > > > > > Hi all! > > > > > > > > > > I'm using the built-in camera in my app to take a picture > and to > > > > > save > > > > > > > > it in a database. So, from my activity, I launch the camera, > take > > > a > > > > > > > > picture and go back to the activity (thanks to > "onActivityResult" > > > > > > > > method). Here, I store the picture in the database and I > delete > > > it > > > > > > > > from the phone. Seems to be working properly: the picture is > > > being > > > > > > > > deleted from the sdcard but if you go to the gallery app that > > > comes > > > > > > > > with the device, the picture is being displayed but as a > "wrong > > > > > file", > > > > > > > > so you can see that there is/was a picture there but you > can't > > > open > > > > > it > > > > > > > > or even see the preview. But I can delete it from the > gallery > > > app > > > > > > > > manually (selecting them and then deleting). How can i do > this > > > > > > > > programatically? > > > > > > > > > > Thanks a lot! I really need help with this > > > > > > > > > -- > > > > > > > You received this message because you are subscribed to the > Google > > > > > > > Groups "Android Developers" group. > > > > > > > To post to this group, send email to > > > > > [email protected] > > > > > > > To unsubscribe from this group, send email to > > > > > > > [email protected] > > > > > > > For more options, visit this group at > > > > > > >http://groups.google.com/group/android-developers?hl=en > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > > > Groups "Android Developers" group. > > > > > To post to this group, send email to > > > [email protected] > > > > > To unsubscribe from this group, send email to > > > > > [email protected] > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/android-developers?hl=en > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Android Developers" group. > > > To post to this group, send email to > [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

