Refer to Android camera call, http://blog.csdn.net/yanzi1225627/article/details/33028041/, thank you
How to call the camera do not repeat, the following is the JS call camera code:
Java:
1**2* Created by Administrator on 2016/6/24 0024.3*/4 Public classQrcodehtmlactivityextendsActivity {5 /**6 * Web page7 */8 PrivateWebView Wvqrcode;9 @OverrideTen protected voidonCreate (Bundle savedinstancestate) { One Super. OnCreate (savedinstancestate); A Setcontentview (r.layout.activity_html_qrcode); - Initview (); - Setwebview (); the } - - Private voidInitview () { -Wvqrcode =(WebView) Findviewbyid (r.id.wv_qrcode); + } - + /** A * Set Page at */ - Private voidSetwebview () { - //allow JavaScript to execute -Wvqrcode.getsettings (). setjavascriptenabled (true); - //passing objects to JS -Wvqrcode.addjavascriptinterface (NewShowcamera (), "Camera"); in //the small partner of node can be saved to assets - //wvqrcode.loadurl ("File:///android_asset/qrcode.html "); to //Visit Web pages +Wvqrcode.loadurl ("http://192.168.253.1:3000/htmls/QRCode.html"); - } the Public Final classShowcamera { * //HTML calls this method to pass the data, the annotations must be kept, otherwise it will go wrong. $ @JavascriptInterfacePanax Notoginseng Public voidShowcamera () { -Intent Intent =NewIntent (qrcodehtmlactivity. This, Qrcodesurfaceactivity.class); the //call to open the camera's interface +Qrcodehtmlactivity. This. StartActivity (intent); A } the } +}
Html:
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <title>Two-dimensional code call</title>6 <Scripttype= "Text/javascript">7 functionShowqrcode () {8 Window.camera.showCamera ();9 }Ten </Script> One </Head> A <Body> - <H3>This example is a click button to call the camera scan QR code</H3> - <inputtype= "button"name=""value= "click Invoke"onclick= "Javascript:showqrcode ()"/> the </Body> - </HTML>
Github:https://github.com/weifengzz/androidjsqrcode
Android and JS mixed (JS call Android camera)