What you are after is the WebView method addJavaScriptInterface:

http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object,
java.lang.String)

As the name implies, this creates an interface between Javascript in
the webpage and your Java code. You''ll need to use that to have your
JS return values to your Java object.

If the computations you refer to are long-running then do them in an
AsyncTask in the Activity hosting the WebView. You'll inject the
values back into the loaded webpage using JS. You can pass javascript
code to loadUrl() and it will execute. For for instance you can
generate from JS code that modified the elements you want after the
computation completed.

Jonathan

On Mar 13, 8:44 pm, perumal316 <perumal...@gmail.com> wrote:
> Hi TreKing,
>
> I already have my own webview application that will load a custom
> webpage. I need to get user inputs from the data field in the webpage
> to do some computation and insert back the result into the webpage.
>
> I am thinking of writing a background service and couple it with this
> application. But I am not sure how to do the interaction with the
> webpage. Getting and inserting into the data field.
>
> Is this possible to be done through a background service?
>
> Regards,
> Perumal
>
> On Mar 14, 9:34 am, TreKing <treking...@gmail.com> wrote:
>
>
>
>
>
>
>
> > On Sun, Mar 13, 2011 at 8:25 PM, perumal316 <perumal...@gmail.com> wrote:
> > > I want it to become active when my another application is started.
>
> > Any idea how do I detect the activation of another application?
>
> > You don't detect another application. You start your service from your
> > Activity.
>
> > > Should I package the application and service together?
>
> > A Service has to be packaged with *some* application - particularly the one
> > that is going to be starting it. So yeah.
>
> > --------------------------------------------------------------------------- 
> > ­----------------------
> > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> > transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to