我试图从带有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.(ViewRoot.java:258) E/WindowManager( 2822): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
任何人都可以解释我的问题在哪里?谢谢
我从phonegap google group获得的答案:
this.ctx.sendJavascript("myJavaScriptFunction");