Save images inside webview Android SDK - android

Im making a simple app for some friends to use on there android phone that shows my website with images. Im using a webview to show the website inside the app. I want the users, to be able to save the actual image. Either by Hold down on the image or actually clicking a button. Been looking around on googles docs ands cant seem to find anything for this.

I haven't actually played around with this yet, but from the docs it appears you have at least two (non-deprecated) options:
getHitTestResult()
requestImageRef(Message msg)
According to the documentation you can use the first option to test for IMAGE_TYPE as result, and a url to the image is provided as well:
If a HTML::img tag is found, the HitTestResult type is set to
IMAGE_TYPE and the url is set in the "extra" field.
The second option will give you a similar result:
Request the url of the image last touched by the user. msg will be
sent to its target with a String representing the url as its object.
Not sure if these options are compatible with a 'long click' too though.
Alternatively, how did you have in mind to link clicking a button to a specific image? Depending on your solution for this, you may also be able to simply capture all loaded image resources using onLoadResource(WebView view, String url), build a list of image references and download the one that button click refers too.

Related

filter json results into image path

Hello i am using MIT App Inventor 2 to make an app that runs on an old (spare) android phone to display the folder.jpg of currently playing movie (later on I also want to do that with music).
I can't filter the path to use, for example this is the result of the json:
{"id":"VideoGetItem","jsonrpc":"2.0","result":{"item":{"id":1,"label":"2012","thumbnail":"image://F%3a%5cMovies%5c2012%5cfolder.jpg/","type":"movie"}}}
I want to keep: image://F%3a%5cMovies%5c2012%5cfolder.jpg which is the dvd cover (and maybe the label: 2012 which is the title of the movie).
I tried various options like making a list but then I still get text with lot of params between '()'
Can someone help me with this?
Thanks
Use the JSON decode block together with the lookup in pairs block. As you can see, it helps to use Do it...
I have something that is doing it for me for starters.
I see a flaw but that's in Kodi(.tv) itself (I am not a fan of the library system in kodi, so I put a folder.jpg in every drawer of a movie, but sometimes kodi doesn't display it and presents me with a video preview of the movie, I have to sort that out with kodi developers)
For now I am glad I have it working,
solution picture

How to access linkify number

I need to make all numbers in a string become links.
The expected action when any of these links is clicked is to append the clicked number to an existing string.
I managed to linkify the numbers by using the following code:
Pattern myMatcher = Pattern.compile("[0-9]*");
Linkify.addLinks(myString, myMatcher, null);
How can I access and retrieve the clicked number in this case?
I tried looking in other questions related to Linkify but seems all are describing ways to have an action that opens an activity or open the default app for that link type (email address/web URL/etc.)
Thanks in advance for you help :)
You can Customize Linkify to append any predefiened string(scheme) into that.
Take a look at the following post Android Developer Blogspot (Search for "Custom Linkify")
For clarity I am describing a portion of that post here:
Linkify will automatically append whatever is matched to a scheme that
is supplied to it, so for the sake of argument let's assume we have a
ContentProvider that matches the following content URI:
content://com.google.android.wikinotes.db.wikinotes/wikinotes/WikiWord
The WikiWord part will be appended by Linkify when it finds a match,
so we just need the part before that as our scheme.
Now that we have these two things, we use Linkify to connect them up:
Pattern wikiWordMatcher = Pattern.compile("\\b[A-Z]+[a-z0-9]+[A-Z][A-Za-z0-9]+\\b");
String wikiViewURL = "content://com.google.android.wikinotes.db.wikinotes/wikinotes/";
Linkify.addLinks(noteView, wikiWordMatcher, wikiViewURL);
Linkify can be used multiple times on the same view to add more links,
so using this after the Default Linkify call means that the existing
active links will be maintained and the new WikiWords will be added.
You could define more Linkify actions and keep applying them to the
same TextView if you wanted to.
Now, if we have a WikiWord in the TextView, let's say MyToDoList,
Linkify will turn it into an active link with the content URI:
content://com.google.android.wikinotes.db.wikinotes/wikinotes/MyToDoList
and if you click on it, Android will fire the default intent for that
content URI.
For this to all work, you will need a ContentProvider that understands
that Content URI, and you will need a default activity capable of
doing something with the resulting data. I plan to cover these in
future blog entries (and soon). In fact, the whole Wiki Note Pad
application is currently undergoing some clean up and review, and will
then hopefully be released as a sample application.

Android webView; Not displaying image having relative path

While trying to use loadUrl(String url, Map additionalHttpHeaders) method of webView, the response that I receive is not able to display the image. Instead of the image, a question mark substitute is used.
So, I tried to hit the same URL using Java code. The HTML code received during this process showed that the tag's src attribute was using a relative location.
On passing this same HTML code to webView's loadData() method, I get the same output as mentioned in the first case.
Anyway to fix this issue? (In the additionalHttpHeaders I was passing the authorization header)

Wikipedia redirect target containing a # symbol

I am doing direct queries to wikipedia's website via an android app.
However, sometimes when I get "REDIRECT" queries, and my redirect suggestion has a # sign in it, I don't really know how to handle it. I know I can just throw everything out past the # sign, but that means I'm looking up something that is relatively unimportant.
Here is an example link;
http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles=Poof_(The_Fairly_OddParents)&format=json
I can just redirect to List_of_The_Fairly_OddParents_characters, but I want to know if there is anything useful I can do with the "#Poof" because I'm sure that the information is there for a reason.
I could not find anything on MediaWiki APIs.
Please help!
Thanks
Most of the time the part after the hash is a section title (though it is simply appended to the new URL, so it can be, and occasionally is, used to point to other kinds of anchors), so you can locate the section (with the mobileview action for example) and with the section index you can query the HTML for that section. (extracts does not support sections, so you you must use something else and enforce length limits manually.)
The hash points to a named anchor or ID in the target document. So if you're parsing the page content, then ideally you'd find the anchor tag or ID and return the content that follows that element, rather than starting at the beginning of the content.

How do I do a lazy load of images in ListView from PHP server to Android

I am new to android & exploring it.I need to load image of User dynamically in my list shown below
list of Users!
I use one static image to show as user image from my resource folder. this list is dynamic & get change as my location get change but only when i refresh it.
AddObjectToList(jFan_Data.getString("uniqid").toString(),R.drawable.ic_add, jFan_Data.getString("name"), jFan_Data.getString("distance"));
on click of the list item need to display the complete profile of user. i succeed to show complete profile on click i need to show image of user here as well
user_profile!
How i get the data from php(Please gone through) -> android List View having jsonObject
now how i get images of users from my php server... would greatly appreciate any sample code,scripts, and pointers to where I could find more information to better understand the inner working. Also, pretty much interested to know how i use other framework or is there are better frameworks to do what I want to, I am happy to learn about that!!!

Categories

Resources