Extracting image from a page displayed in Android Webview - android

My app displays third party website pages in webview based on certain search. Now if user clicks on some image (e.g. small product image on a site), I'd like to capture that image in my app?
I can capture URL in shouldOverrideUrlLoading() in my app but don't know how to extract image out of it.
Any link/suggestion is appreciated.
Thanks

Once you have the URL of the image, I'd suggest that you create an HttpURLConnection[1] to it, then decode the response into a Bitmap with BitmapFactory[2].
[1] http://developer.android.com/reference/java/net/HttpURLConnection.html
[2] http://developer.android.com/reference/android/graphics/BitmapFactory.html

Related

How to Share Images from Browser to Android Native Apps?

I'm looking for ways to share images from web browser in android. Either by pasting a link to load target image(not as a thumbnail on the left that usual comes from meta), or directly sending the image through share.
I've used Chrome's Web Share API but it only gives options to share title, text and url. If there is an image in this url as a meta, it's loading as a thumbnail on the left. But I need to share the actual image directly. Please help.

Use Google search by Image uploading an image from gallery

I'm trying to create an Android application to recognize an image by Google images search. I want that a user provides an image to Google (by uploading it from the gallery) and Google returns the web page with the best guess for the loaded image.
I would open the google images search page (https://www.google.it/imghp?hl=it&tab=wi&ei=ZzCGWIW9EcyuswHu7KroDA&ved=0EKouCBYoAQ) inside of my activity.
But, in this page, in order to see the camera icon next to the search bar that lets you upload images, you must set your browser with the "pc view".
So how can I open in my activity this page directly in "view PC" mode? In addition there is a way to directly execute the image search using Google image search without opening the associated page but through an http request?
I am also interested in different approaches to the problem.
Thanks in advance.
To open the page in PC mode, you could set the user agent to that of a desktop browser
webview.getSettings().setUserAgentString("DESKTOP_USERAGENT");
An alternative would be to send the image to Chrome and allow the user to perform the reverse image search using the built-in menu, but that is no longer a native solution.

How to get thumbnail of an image from it's web url in Android without full image download

I have list of urls relevant images loaded on to a server, i need to show thumbnail of these images in the ListView with out download of the image.
Images will be downloaded on next screen when user go in details page.
Find out who manages the server. Contact that person. Ask them "hey, can you please give me alternative URLs for these that will return thumbnail images"? If you get the alternative URLs, use them with your favorite image-loading library to get the thumbnails.
Otherwise, it is impossible to get a thumbnail for an image that you do not have.

Google+ share image using URL like Facebook

I'm currently looking for a way to share in Google+ using URL from web and not from local storage. Problem is that I've used UniversalImageLoader to cache my image and I don't have the image file of the images I wanted to post on my share. I wanted it to be as simple the way facebook done their sharing but using the setContentUrl(Uri.parse(IMG_URL)) will give me the way I wanted it minus the image URL below the post.
Other workarounds I'm thinking is to download the image using the URL, store it somewhere on the device then share it using the setStream(Uri.parse(IMG_URI)) but only problem is that I will need to wait more compared to sharing using URL.
Now is there's any way I can achieve a faster image sharing on Google+? Or if ever is there's a way I can convert the cached file back into image so that I can share it using Stream?

Android browser downloading images automatically

When I visit my site from android (Froyo 2.2) browser and when i click to view image it start to automatically download that image instead of displaying the image in browser.
How can I display my images in browser instead of downloading them?
My browser is set up to load images in settings and I can view pictures on other sites without downloading them to my sd card or phone memory.
Thanks!
If your site when you click on the image send you directly to the image file then that's probably why the android browser tries to download it since he understands it as file. Maybe you should try to display the image in an html file.
For example when you click on an image, it could direct you to an html file with a parameter of the image name. Then inside that html you can have a javascript code that will load and display that image.

Categories

Resources