I am trying to launch an intent to open the zxing barcode scanner from a link in a webview.
I have created a menu item that launches the zxing scanner from the menu, when someone hits the menu button on their phone. But some tablets don’t have that menu button, so I need to add access to the scanner from the webview.
I have no clue where to start. I figured there would be a way to add a javascript code to the webview, that when someone clicks on a link, it calls the android:id=”@+id/scanNow” or something equivalent.
Or is there a way for me to launch:
case R.id.scanNow:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
return true;
from the html web page?
What you probably want is to have some javascript in your webview and link it to your Android application. For that, you will need to use addJavascriptInterface.
Check out this link and this link for more explanations.