? ? Before writing a QR Code scan demo, use the zxing frame and click Download. Perhaps scan QR code in some problems, such as the resolution of compressed images. Adjust the size of the scanned form, and so on.
Perhaps the unit required to do a scan login implementation, found that the difficulty is how to know that you are scanning this computer, the background must be acquired (background technical problems) and then the reference to me, and then passed to the background, the background inference login can. This allows you to log in directly by passing a number of parameters on your own scan. Effects such as the following:
Approximate code implementation: Scan Jump:
Scan login Acase r.id.tv_more_qr:if (Pventquickclick.isfastdoubleclick ()) {break;} Dialogutils.showcommonpopupwindow (context); Myapplication.checklogin (Context, new Appcallback () {@Overridepublic void Appcallback (String userid) {//TODO Auto-generated method Stubdialogutils.dismisscommonpopupwindow (); Intent opencameraintent = new Intent (context, CAPTUREACTIVITY.CLASS);//zing Framework class Startactivityforresult (opencameraintent,0);}); Break
Then the scan will return the results of the scan in Onactivityresult
@Overridepublic void Onactivityresult (int requestcode, int resultcode, Intent data) {Super.onactivityresult ( Requestcode, ResultCode, data); if (ResultCode = = Getactivity (). RESULT_OK) {Bundle bundle = Data.getextras (); String Qrresult = bundle.getstring ("result"); Logutils.log_e ("Qrresult", qrresult); int scan= qrresult.indexof ("+");//For Tangent string inference//Login if (scan>0) {string starts = Qrresult.substring (0, scan); String ends = qrresult.substring (scan+1, Qrresult.length ()); Logutils.log_e ("starts", starts+ "..." +ends), if (Ends.equals ("Qrlogin")) {Intent Intent = new Intent (context, Qrlogin.class);//Jump to confirm Login interface Intent.putextra ("Scanresult", starts); StartActivity (intent);}} else if (Stringutils.geturl (Qrresult)) {//is the HTML link to jump directly to the browser, such as apk download, etc. intent Intent =new intent (); Intent.setaction ("Android.intent.action.VIEW"); Uri content_url =uri.parse (Qrresult); Intent.setdata (Content_url); StartActivity (intent);} else if (! Stringutils.geturl (Qrresult)) {Toast.maketext (getactivity (), "Sir, you can't find it!! !
", 0). Show ();}}}
Then jump to the Confirm login screen: Click to infer:
@Overrideprotected void Baseonclick (View v) {switch (V.getid ()) {case R.id.tv_qr_login://toast.maketext (qrlogin.this, "Login", 0). Show ();D Ialogutils.showcommonpopupwindow (qrlogin.this); linkedhashmap<string, string> get_checkqrcodelogin = new linkedhashmap<string, String> (); get_ Checkqrcodelogin.put ("Key", Myapplication.getuserstate ("Loginkey"));//Android fixed to 1get_checkqrcodelogin.put (" SessionID ", sessionid);//Android fixed to 1httpmanager.getcheckqrcodelogin (Get_checkqrcodelogin, New Netcallback () {@ Overridepublic void callback (String result) {Dialogutils.dismisscommonpopupwindow (); Logutils.log_e ("Getcheckqrcodelogin", result); final Checkqrcodelogin Checkqrcode = Jsonutils.getbeanfromjson (Result , Checkqrcodelogin.class), if (Checkqrcode.code.equals ("1")) {Toast.maketext (qrlogin.this, "login succeeded", 0). Show (); Finish ( );}}}); Break
This enables QR code to be scanned for login. Two-dimensional code demo download. Resolve scan box size and picture compression issues
Android implementation QR Code scan login Page