How can I display all images from a specific folder on android gallery like, for example, whatapp does.
I`m using MediaScannerConnectionClient
File folder = new File("/sdcard/myfolder/");
allFiles = folder.list();
SCAN_PATH=Environment.getExternalStorageDirectory().toString()+"/myfolder/"+allFiles[0];
@Override
public void onScanCompleted(String path, Uri uri) {
try {
if (uri != null) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
startActivity(intent);
}
} finally {
conn.disconnect();
conn = null;
}
}
private void startScan() {
if (conn != null) {
conn.disconnect();
}
conn = new MediaScannerConnection(this, this);
conn.connect();
}
@Override
public void onMediaScannerConnected() {
conn.scanFile(SCAN_PATH, "image/*");
}
But I`m getting a error at this point:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
startActivity(intent);
Specific here:
startActivity(intent);
Fail to get type for: content://media/external/images/media/267830
No Activity found to handle Intent
On onScanCompleted my path and uri parameters are not null.
Hi you can use the code below, i hope it helps you .