I am new to android development, i am doing small application to capture USB Camrea image using UVCCamera
.
I have captured image using UVCCamera
and stored in sdcard like this
File filepath = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "IMG_"+getDateTime() + ".jpg");
mCameraClient.captureStill(filepath.toString());
here mCameraClient will intract with UVC Camera and capture image and store in that path and it will callback method onCaptureDone
@Override
public void onCaptureDone(final String path) {
// TODO Auto-generated method stub
Log.e(TAG, "onCaptureDone called");
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
//Toast -- Images Saved.
}
});
}
};
Then i am invoking gallery from an image button onClickListener
private MediaScannerConnection conn;
File folder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM));
File[] mImagefile = folder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String filename) {
return filename.endsWith(".jpg");
}
});
if (mImagefile.length > 0) {
SCAN_PATH = folder.toString() + "/"
+ mImagefile[mImagefile.length -1].getName();
Log.e(TAG, "SCAN PATH = " + SCAN_PATH);
if (conn != null) {
conn.disconnect();
}
conn = new MediaScannerConnection(this, this);
conn.connect();
} else {
//Toast -- No Images Available
}
If filter successful.
@Override
public void onMediaScannerConnected() {
// TODO Auto-generated method stub
Log.e(TAG, "onMediaScannerConnected");
;
conn.scanFile(SCAN_PATH, null);
}
@Override
public void onScanCompleted(String path, Uri uri) {
// TODO Auto-generated method stub
try {
Log.e(TAG, "OnCompleted path = " + path);
if (uri != null) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
startActivity(intent);
}
} finally {
Log.e(TAG, "OnCompleted Disconnecting");
conn.disconnect();
conn = null;
}
}
Here my problem was in gallery all captured images was not displaying.
And i have checked in saved directory, there all images was stored successfully.[Images was not corrupted, i have verified]
And i have checked in default gallery application, in that also those images was not displaying.
Please help me on this.
Edit 1:
I have observed one thing, when i capture and saved image, it not showing in gallery but after some time like 2-3Hrs its was appearing in gallery. I WANT TO KNOW WHY LIKE THIS HAPPENING?
Thanks