我有一個網絡的服務在這一我已經加入的AndroidAndroid的網絡視圖錯誤I /鉻:[INFO:控制檯(1)]「未捕獲的ReferenceError:
條形碼讀取器因此具有的幫助JavaScript的我從網上查看打電話給我的條碼閱讀器因此對於I followed this
,並設計了服務器端... 我已經給這個
在JavaScript的
function mybarcd() {
MyApp.mybarcdt();
}
function actfromAnd(msg){
document.getElementById("brcd").value = msg;
}
at HTML/PHP
<div class="data">
<input id="brcd" type="text" value=""/>
<button type="button" onClick="mybarcd()">SCAN</button>
</div>
在Android上側 在網頁視圖
webView.addJavascriptInterface(new WebAppInterface(this), "MyApp");
和新的JS接口
@JavascriptInterface
public void mybarcdt() {
IntentIntegrator intentIntegrator = new IntentIntegrator(Main_A.this);
intentIntegrator.setBeepEnabled(true);
intentIntegrator.setOrientationLocked(true);
intentIntegrator.setPrompt("Scan Barcode");
intentIntegrator.initiateScan();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null) {
if (result.getContents() == null) {
Log.d("ScanActivity", "Cancelled scan");
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
Log.d("ScanActivity", "Scanned");
String bcval = result.getContents();
if (android.os.Build.VERSION.SDK_INT < 19) {
webView.loadUrl("javascript:actfromAnd(\""+bcval+"\")");
}else{
webView.evaluateJavascript("javascript:actfromAnd(\""+bcval+"\")", null);
}
System.out.println("javascript:actfromAnd(\""+bcval+"\")");
}
} else
super.onActivityResult(requestCode, resultCode, data);
}
我的問題是,它在SI做工精細與Js的Html/PHP文件在同一頁或單獨的頁面我已經測試了它的掃描和更新輸入框中的值...
但它不工作,因爲我在一個webview中使用多個頁面或框架... 其缺少的JS值...如何形成服務器其開幕掃描儀在點擊...但掃描後的價值是沒有傳遞到輸入框與JS我得到這個錯誤.....
I/chromium: [INFO:CONSOLE(1)] "Uncaught ReferenceError: actfromAnd is not defined", source: (1)
更新
1)I HAVA在側與JS嘗試這種在靜態網頁,PHP/HTM大號
頁 2)我也有同樣想在一個靜態頁面與JS單獨的頁面
在上述兩個條件其工作的罰款
但在我的網絡服務,我已經給它在成功運行相同的JS文件靜態頁面我有一個單獨的JS文件我的Web服務和靜態頁面其靜態工作正常,但不工作在我的web服務生活..如何加載JS因爲點擊它從JS和它的開幕相機但掃描後響應它不會網絡輸入
據我所知,我得到錯誤,因爲...
In my Live Page I have a MainMenu Inside that menu when I select a application its loading in
iframe
So my Android Activity responce after scanning Is pinging to that Mainmenu page But for menu there is no Js function namedactfromAnd
So I am getting Error...
在這裏,我不能給特定頁面(iframe
)因爲根據菜單的URL它將改變我能給的也只有登錄或MainMenu的鏈接directly.but沒有爲特定的頁面裏面的菜單
可以任何人建議我這種...
哪裏是actfrom和方法寫的?如果它在PHP中是腳本寫入輸出頁面? –
'actfromAnd'是用JS和Android編寫的兩種形式android我將用JS發送我的條形碼輸出到'actfromAndroid',但它的工作原理如何,但是......它不適用於我的情況,請檢查我的更新問題...由於'iframe'沒有響應...我的應用程序發送數據到菜單頁面不是'iframe頁面'所以我得到錯誤 – MLN
嘗試與父母。<< yourfunction >>名稱如果您使用iframe –