Basically what I'm trying to do is allow the user to take a picture, then after they save the picture they can open the gallery(inside the app) and view the picture. However the pictures do not show show up in the gallery. This is what I have thus far. This is what the directory looks like when a picture is taken and saved:
/storage/sdcard0/Android/data/'my app'/files/ArcFlash/study1/Transformer/trans1/trans1_time_date.png
After the picture intent, I have my onActivityResult
(I compress the picture):
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == 1)
{
if(resultCode == RESULT_OK)
{
SharedPreferences sharedPrefs = getSharedPreferences("userPrefs", Context.MODE_PRIVATE);
String path = sharedPrefs.getString("path", null);
filesToScan.add(path);//ex: /storage/sdcard0/Android/data/'my app'/files/....
Bitmap capturedImage;
if(path != null)
{
capturedImage = BitmapFactory.decodeFile(path);
//Bitmap bitmap = Bitmap.createScaledBitmap(capturedImage, 60, 60, true);
File newPic = new File(path);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(newPic);
capturedImage.compress(Bitmap.CompressFormat.JPEG, 70, fos);
fos.flush();
fos.close();
String test = "file://"+ context.getExternalFilesDir(null).toString() + "/ArcFlash/";
for(int i = 0; i < filesToScan.size(); ++i)
{
File pic = new File(filesToScan.get(i));
Uri uri = Uri.fromFile(pic);
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, uri));
}
}
catch(Exception ex)
{
handler.Log(ex.getMessage(), "onActivityResult()", context);
Log.i("customException", "error compressing image: " + ex.getMessage());
}
}
}
}
}
my filesToScan
is an ArrayList<String>