Android Question Pass html events to an activity

Sub7

Active Member
Licensed User
Longtime User
Hello,
i have an app which use downloaded html files inside webview to show contents to the user.
I use a sqlite db to populate item names, menu descriptions, buttons text, icons, and a table which contain a glossary for some specific terms, for example:

db>table_glossary
ID NAME SHORTDESCR
1 ETHYL THIOGLYCOLATE ADDITIVE USED FOR..
2 ETHYL ACETATE SOLVENT USED IN..

In my html pages, when needed i need to put an hyperlink than once is clicked will open a new activity and where data is obtained from glossary_table content, something like this:

"The #ethyl_acetate(click, new window > query > result) is commonly used for production of #foo"

I know how to interact with db and populate a list, label or textview,
but i dont know if and how is possible to pass values taken from html to my queries.
I also know that would be more easy to me to put the glossary of terms inside another html file and just link the hrefs to that file, but for various reasons i need to keep that informations stored in a sqlite table, separated from html files.

Any suggestion? i tried to search in forum but with no luck or i may missed it, sorry for my horrible english.

Thank you
 

Sub7

Active Member
Licensed User
Longtime User
If you can inject Javascript into the html then you can get the click events (I am not sure how to get the click objects though)
Have a look at warwound's webviewextras
Thanks The desolatedsoul, i will try that.
Anyone has other possible solutions?
 
Upvote 0

Sub7

Active Member
Licensed User
Longtime User
See DBUtils.ExecuteHtml. It creates a table with clickable links. These links are handled with the OverideUrl event.

http://www.b4x.com/android/forum/threads/dbutils-android-databases-are-now-simple.8475/#content

Sorry i didn't explain my problem well.
I need to intercept user actions from a local html file and pass href values (or through js) outside the webview.
For example <a href="123"> #foo </a> i want #foo href to be intercepted (123) so i can query the db based on that specific value.
I don't have to draw html from sqlite, in the database i have a table that contain a vocabulary which is indipendent, separated, and used by html and other application functions.
I don't know if this's the besta way to accomplish this task, my html files get often updated (and redownloaded) from my server,
instead the vocabulary is stored locally.
ty
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Search the forum for JavascriptInterface.

A JavascriptInterface enables javascript methods in a webpage to call Subs in your B4A project.
If you have control over the webpage content then you can update it so that a click on a link calls a B4A Sub.
If you have no control over the webpage content then things are tricky - you'd need to inject javascript into the loaded webpage so that clicks call a B4A Sub.

Martin.
 
Upvote 0

Sub7

Active Member
Licensed User
Longtime User
Search the forum for JavascriptInterface.

A JavascriptInterface enables javascript methods in a webpage to call Subs in your B4A project.
If you have control over the webpage content then you can update it so that a click on a link calls a B4A Sub.
If you have no control over the webpage content then things are tricky - you'd need to inject javascript into the loaded webpage so that clicks call a B4A Sub.

Martin.
That's exactly what i need, thank you.
 
Upvote 0
Top