Android : How to get images from webserver(mysql) with relative-path? - android

I already know how to use PHP+MySQL to get the URL path of image and turn it to a bitmap in android. But now I want to get the images from another way. If the image is stored by relative-path in MySQL, how can I turn it to a bitmap?
Are there any tutorials or demos?

Related

Why when loading image with Glide as ByteArray into an ImageView doesn't rotate it according to EXIF?

I am using Glide library on Android to load a JPG format image into an ImageView, first I convert it to a ByteArray and then I use the following code:
GlideApp.with(context)
.load(selectedImageByteArray)
.into(image_view)
However, when the selected image orientation EXIF data is equal to "Rotate 270 CW" the image is not rotated by Glide unless I use the following code:
GlideApp.with(context)
.load(selectedImagePath)
.into(image_view)
This way I pass the selected image Uri instead of a ByteArray, why does this happen?
I attach and example (even here in Stack is not rotated):
Because that interface takes a path and nothing else. Kind of annoying since depending on the api level it is not always available. In some of the newer versions of android it is not easy to get the actual path of the file.image
data for that
The short answer is that the data that interface uses is stored in the file, not in the image data itself. There are many stack overflow links about this:
SO

Store images from url in cache and use them as thumbnail or placeholder like whatsapp.

I am developing story feature app like instagram or whatsapp but I got stuck somewhere. I am getting image thumbnail from server as URL but when I try to use it . It take some time to load that image.So I want to Load add thumbnail images from url in previous activity and then set that thumbnail from cache.How I can store url images in cache Hashmap or arraylist to use them in next activity.Please help.I am in trouble right now.
You can use Glide for catching the image from URL.

Path to Local Image Specified in JSON

I'm working with a tutorial fromRay Wenderlich (https://www.raywenderlich.com/124438/android-listview-tutorial). In the tutorial, an image is retrieved via the Internet using a URL specified in the locally stored JSON file:
"image" : "https://www.edamam.com/web-img/341/3417c234dadb687c0d3a45345e86bff4.jpg"
The string is stored in the imageUrl variable:
recipe.imageUrl = recipes.getJSONObject(i).getString("image");
Then the image is loaded using Picasso:
Picasso.with(mContext).load(recipe.imageUrl).placeholder(R.mipmap
.ic_launcher).into(thumbnailImageView);
I would like to change the code in the tutorial so that the image is retrieved from the drawable folder within the app, rather than via the Internet. I've been working on this on and off for several days. I assumed it was a matter of changing the URL in the JSON data so that it specified a path to the image file in the drawable folder like this:
"image" : "android.resource://com.raywenderlich.alltherecipes/drawable/chicken.jpg"
So far I've been unsuccessful. Am I on the right path, or am I way off? I'm an Android newbie. I'm used to working with plists in Xcode (although I'm no expert there, either).

Android How to receive jpg from web Api Call and Display it in ImageView

I have a quick question how to receive a jpg image from a web api call.
String result = webApiManager.getBarcode(dataStorageManager.currentUser.CustomerID);
This method returns a jpg image but I am unsure how to handle it and display it in an ImageView. Furthermore, what data type is a jpg image and how do I convert it into an image that I can display using an ImageView. Can someone point me in the right direction on how to accomplish this. Thanks for your time.
Regards,
Ryan
instead of returning the image as a jpg...why not just return the URL to the image and then use AsyncTask in processing it...
It will be easier and faster that way... just my 2cents

Use BitmapFactory.decodeFile() but image is not Decoded

My Problem is I am getting Image from Gallery & use BitmapFactory.decodeResource() for Convert the image into bitmap but the Problem is the Image is get in Emulator but not in Real Device, In Real Device the Bitmap value is getting null. following is my code for decode Gallery Image.
String Galleryimagepath="/mnt/sdcard/DCIM/.thumbnails/1308059312410.jpg";
bmpImage = BitmapFactory.decodeFile(Galleryimagepath);
drawable = new BitmapDrawable(bmpImage);
mRlayoutmainimage.setBackgroundDrawable(drawable);
Any Help would be appreciated.
Yashwanth is right, the path may be different between device and emulator, further, the path may different device to device as well. You'd be better off getting a content URI for the image you want and using MediaStore.Images.Thumbnails.getThumbnail() to get the bitmap you're looking for.
MediaStore.Images.Thumbnails
I think sd card path on real device is different. you might have to use something like
Environment.getExternalStorageState()
check the following link.
Find an external SD card location

Categories

Resources