How to find duplicate images fetching from gallery in android
Date : March 29 2020, 07:55 AM
I wish this help you You must be getting a URI of the image. Maintain a HashSet of the URIs. HashSet will remove the duplicates for you. In the textview you can just show the size of the HashSet, that will always show the unique number of images.
|
How create Custom gallery by reading all images stored in android internal storage
Date : March 29 2020, 07:55 AM
hope this fix your issue if i follow your question, than you can retrieve the list of file with .jpg extension run a loop on list and show in imageview. File root = new File("/sdcard/MyCollection");
final String files[] = root.list(imageFilter);
FilenameFilter imageFilter = new FilenameFilter() {
File f;
public boolean accept(File dir, String name) {
if(name.endsWith(".jpg")) {
return true;
}
f = new File(dir.getAbsolutePath()+"/"+name);
return f.isDirectory();
}
};
|
How to show images from assets or internal storage in a gallery to pick from?
Date : March 29 2020, 07:55 AM
I wish this helpful for you I created a "Gallery" myself by using a GridView. I used the code from that side to create an ImageAdapter, with a few changes: public class ImageAdapter extends BaseAdapter {
private ArrayList <String> data = new ArrayList();
// I'm using a yamlReader to fill in the data, but it could instead just be hardcoded.
fillDataWithImageNames();
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
// if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
// The images are in /app/assets/images/thumbnails/example.jpeg
imageView.setImageDrawable(loadThumb("images/thumbnails/" + data.get(position) + ".jpeg"));
return imageView;
}
// references to our images
private Drawable loadThumb(String path) {
try {
// get input stream
InputStream ims = mContext.getAssets().open(path);
// load image as Drawable
Drawable d = Drawable.createFromStream(ims, null);
// set image to ImageView
return d;
}
catch(IOException ex) {
return null;
}
}
|
Android mediastore not returning all internal storage images in phone. It is only showing images lockscreen and wallpape
Date : March 29 2020, 07:55 AM
Does that help Use this to get all images from internal and External storage and do not forget to add permission in your manifest file. int dataColumnIndex;
int bucketColumnIndex;
int displayNameColumnIndex;
String GalleryThumbnail_Path;
String bucket;
String displayName;
int imageCounter = 0;
Thread getImages = new Thread(new Runnable() {
@Override
public void run() {
String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.BUCKET_DISPLAY_NAME
};
String orderBy = MediaStore.Images.Media.DATE_TAKEN;
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
try {
Cursor cursor = context.getContentResolver().query(uri, columns, null, null, orderBy);
assert cursor != null;
int mCount = cursor.getCount();
for (int i = mCount - 1; i >= 0; i--) {
if (imageCounter <= 370) {
cursor.moveToPosition(i);
dataColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
bucketColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
displayNameColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME);
GalleryThumbnail_Path = cursor.getString(dataColumnIndex);
bucket = cursor.getString(bucketColumnIndex);
displayName = cursor.getString(displayNameColumnIndex);
myimagesPath.add(GalleryThumbnail_Path);
myStorage.add(bucket + "-->" + displayName);
imageCounter++;
Log.e("Recents " + i + "-->>", "Added to bucket");
} else {
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
|
Copy image file from Android internal storage to gallery
Date : March 29 2020, 07:55 AM
|