How to set image on a imageview in webview in android - android

Trying to change the profile image on the web view.
But when trying the updated image showing a crashed image.
webView.loadUrl("javascript: (function() {document.getElementById('SelectedImage').src='"+profilePath+"';}) ();");

If profilePath is a Uri object, then you need to get the absolute path from the object. Use File f = new File(profilePath.toString());

Related

Stored Image URI path is not working with Android Image View

I am storing image URI path into mobile database, when I am trying this path for the first time with image view then it is working fine means I am able to see image with the stored path but second time I am using the same path with image view but it is not working (image view is getting blank).
Try this line of code
ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail);
thumbnail.setImageURI(Uri.parse(imageUri));
where imageUri is a string datatype..

How to save image file directly to image gallery in android

Is there any good way to save image into gallary using File object?
I want to do like this
File file = new File("path to image gallery","empty.jpg");
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").save(file);
I believe JakeWharton meant that ??
picasso issue

Set ImageView through Uri

I am developing Android Web app using restfull web Services.I have written Image in my system as jpg file .Now i need to set Image into ImageView.So I have tried like this
ImageView hotelLogo;
hotelLogo = (ImageView) findViewById(R.id.imgViewHotelLogo);
hotelLogo.setImageURI(Uri.parse("D:/images/Image0800.jpg"));
but it doesn't show image in my ImageView.anyone can correct my code?
Use glide or picaso library to load image from server in both also you can load local image

Download image from new Google+ (plus) Photos Of Gallery with Image Extension

In new android version, they have added gplus photo section in gallery.
In my application, i have incorporated the logic of selecting image from it and display to the user using below link of stackoverflow:
Download image from new Google+ (plus) Photos Application
However, i also need image extension as we are sending image raw data with extension of selected picture to the API. gplus returns the image path like this
content://com.google.android.apps.photos.content/0/https%3A%2F%2Flh5.googleusercontent.com%<a bunch of letters and numbers here>
So, how can i get extension of that image also from gplus?? Any idea??
I AM SUCCESSFULLY GETTING BITMAP FROM ABOVE URI. I JUST NEED EXTENSION OF THAT IMAGE NOW.
Thanks.
Use ContentResolver.getType(uri):
Uri uri = // your content://com.google.android.apps.photos.content URI
String mimeType = getContentResolver().getType(uri);
// mimeType will be image/png, image/jpeg, etc.

How to add image to android app?? I reached till Imageview class but could not figure out further

I am very new to Android development.
I am trying to add an image to my Android application by code. I found this, but it is showing some drag and drop way to do it.
I want to do it by coding in my onCreate method.
I managed to do this:
ImageView iv = new ImageView(this);
But could not figure out how to set the image-uri.
I tried the following:
iv.setImageURI(#"C:\Users\SONY\Downloads\slide.butcher.home.jpg");
with and without # but I think I need to pass an URI.
I tried to create an object of android.net.Uri, but it seems it can not be instantiated.
See the uri you have tried is wrong it is located on your local file system.. Instead try to push the image on the device's sdcard with the help of DDMS of eclipse..
Suppose you have pushed it on /sdcard/your_image.jpg. then in your code set your image path as
imageView.setImageUri (Uri.parse("/sdcard/your_image.jpg"));
I m sure you will get it...
ImageView iv = (ImageView)findViewById(v);
iv.setImageResource(R.drawable.image);
iv.setImageURI(#"C:\Users\SONY\Downloads\slide.butcher.home.jpg");
You are trying pass Uri of image which is stored on your Computer!!!!
Copy that file on your device SD Card.
Suppose you copied it under /sdcard/home.jpg
Then use below code to display it in ImageView.
imageView.setImageUri(Uri.parse("/sdcard/home.jpg"));

Categories

Resources