Android& Phonegap:使用loadUrl加载javascript函数时发生错误

时间:2011-11-06 17:06:25

标签: javascript android cordova

我试图从带有Phonegap for Android的java加载我的javascript函数时遇到问题。每当我打电话给

loadUrl("javascript:myJavascriptFunction()");

我总是有这个错误

I/System.out( 2822): loadUrl(javascript:myJavascriptFunction())
I/System.out( 2822): url=javascript:myJavascriptFunction() baseUrl=file:///android_asset/www/
D/PhoneGapLog( 2822): file:///android_asset/www/phonegap-1.1.0.js: Line 920 : JSCallback     Error: Service unavailable.  Stopping callbacks.

我可以看到我的javascript实际上已被调用。但是大约10秒后,我的应用程序因为这个错误退出了:

I/System.out( 2822): onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=javascript:myJavascriptFunction()
E/WindowManager( 2822): android.view.WindowLeaked: Activity com.phonegap.plugin.billing.CallbackBillingActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405d9860 that was originally added here
E/WindowManager( 2822):     at android.view.ViewRoot.<init>(ViewRoot.java:258)
E/WindowManager( 2822):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)

任何人都可以解释我的问题在哪里?感谢

1 个答案:

答案 0 :(得分:6)

我从phonegap google group获得的答案:

 this.ctx.sendJavascript("myJavaScriptFunction");