2011-11-06 32 views
5

我嘗試從Android Phonegap加載我的JavaScript函數時出現問題。每次當我打電話Android&Phonegap:當loadUrl加載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 [email protected] 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) 

任何人都可以解釋我問題在哪裏?由於

回答

6

回答說我從谷歌的PhoneGap組獲得:

this.ctx.sendJavascript("myJavaScriptFunction"); 
+0

這奏效了,我也是如此。您應該將其標記爲有效答案。 – Goldsmith

+0

就設備 - > webview通信是否有任何文檔? –

相關問題