Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Call javascript function from Java

Call javascript function from Java

Put your problem here if it does not fit any of the other categories.

Call javascript function from Java

Postby xoise » Wed Jan 07, 2009 11:03 pm

I'm familiar with doing the opposite of this (calling a java method from javascript using addJavascriptInterface()), but how would I go about calling a javascript function from Java?

More specifically, I'm looking to be able to invoke an action on a WebView when shaking the phone (accelerometer).

Thanks in advance for your help,
Dan
xoise
Freshman
Freshman
 
Posts: 7
Joined: Sun Dec 14, 2008 6:13 pm

Top

Postby MrSnowflake » Thu Jan 08, 2009 9:20 am

There is an example in the samples dir of the SDK.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby xoise » Thu Jan 08, 2009 9:50 am

You mean of the accelerometer? The lunar lander game? I know about that, my question is about invoking javascript from java.
xoise
Freshman
Freshman
 
Posts: 7
Joined: Sun Dec 14, 2008 6:13 pm

Re: Call javascript function from Java

Postby liradev » Fri Feb 25, 2011 11:06 am

Do you have now a solution for your problem?
Or anyone else?
liradev
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Feb 15, 2011 2:38 pm

Re: Call javascript function from Java

Postby xoise » Fri Feb 25, 2011 7:34 pm

Yeah, you can just run the javascript through the url:

Code: Select all
       wv = (WebView) findViewById(R.id.webview);
       WebSettings ws = wv.getSettings();
       ws.setJavaScriptEnabled(true);
        wv.loadUrl("javascript: do_something()");
xoise
Freshman
Freshman
 
Posts: 7
Joined: Sun Dec 14, 2008 6:13 pm

Re: Call javascript function from Java

Postby liradev » Mon Feb 28, 2011 9:21 am

OMG. I had exactly such a call on my Java side but haven't recognized it (it was a callback from a JavaScript side call of a Java method). Thank you very much.
liradev
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Feb 15, 2011 2:38 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 14 guests