Android set image from file - java

I have a question file. I am reading it and I want set image to ImageView from file. For ex:
img.setImageResource(R.mipmap.+"simdikiSoru.getUlkeAdi()");
but it isn't working.

R.mipmap will refer to resources, not files on the device's filesystem.
The best solution is to use one of the many image-loading libraries available for Android, such as Picasso.
Picasso.with(this).load(...).into(img);
where this is your Activity and ... is a File or Uri pointing to your image.
If you do not wish to use a library, then you can create your own subclass of AsyncTask, use BitmapFactory to load in a Bitmap in the task's doInBackground() method, and then set the Bitmap on the ImageView in onPostExecute().

The images your put into res/drawable are handled by Android. The best way to call upon an image in the folder would be
setImageResource(R.drawable.your_image_name)

Related

retrieve the URL images from SQlite

When retrieve the images from Firebase to SQlite it comes as link, so I am trying now to show the images through Picasso as the following:
Picasso.with(context).load(favoritesList.get(position).getFoodImage())
.into(viewHolder.food_image);
but the image not showing. How can I do it?
The first check value of this favoritesList.get(position).getFoodImage(), if not null, paste url to browser and see result. Check your image in xml file and maybe Picasso library error, because in one of my project, Picasso not working but when I using Glide, it's work fine, and i don't understand why :D. BTW you should set placeholder for image.

How to Get Image Path in my App which is Selected from Whats app's Chat?

i have demo application with image view and in this image view i need to set image from which selected from whats app Chat,
Currently i was getting Path of selected image i.e. content://com.whatsapp.provider.media/item/245429
Does any idea to resolve this ?
Thank You in Advance.
There is no image path, as there is no requirement that this Uri point to a file, let alone point to a file that you have direct filesystem access to.
Use an image-loading library (e.g., Glide, Picasso) and provide it the Uri that you get from WhatsApp. Those libraries know how to use ContentResolver and openInputStream() to read in the bytes associated with that content, convert those bytes into a Bitmap using BitmapFactory.decodeStream(), and put the Bitmap into your ImageView.

How to apply wallpaper from assets using built-in cropper?

I want to apply a wallpaper from assets using the default cropper (shown below):
This is usually done by using the WallpaperManager.getCropAndSetWallpaperIntent(ContentUri uri);
However, I can't figure out how the use the images from the assets to do this. The problem is that this method requires Content URI, and all I have from the assets is the "usual" URI: file:///android_asset/...
How can I do this? Is there a workaround to this method?

Get bitmap of the image from browsers

I am trying to get the bitmap of the image which i am viewing in browser. is it possible to get those bitmap values from any of contentProvider. Pl suggest me how to do this. Thanks in advance.
You can use a crawler to get the web-page contents, like Jsoup, then find the image url & either download its bitmap with Glide library or directly load it into a ImageView (using Glide again).

Android: Saved Thumbnail should not appear in gallery

I'm creating a thumbnail from an image. The gallery find the image and list it but I don't want that.
In the folder you're storting the image also create a file called ".nomedia". This will prevent the gallery from showing all images in that folder.
If you dont want the whole folder to be excluded. You could prefix the image name with a dot. Example: ".myimagethumb" this wil prevent the gallery from showing your file.

Categories

Resources