Android realizes two-dimensional code scanning and landing page _android

Source: Internet
Author: User

Before writing a two-dimensional code scanning demo, with the zxing frame, click to download, follow-up scan two-dimensional code appeared some problems, such as the resolution of compressed pictures, adjust the size of the scan window and so on. Follow-up units required to do scan login implementation, found that the difficulty is how to know that you scan the computer, the background must be obtained (background technology problems) and then put this parameter to me, and then passed to the background, the backstage judge login can be. This way, you can simply pass a parameter after you scan it to achieve login.

The effect is as follows:

Approximate code implementation: Scan Jump:

Scan login A case
R.ID.TV_MORE_QR:
if (Pventquickclick.isfastdoubleclick ()) {break
;
}
Dialogutils.showcommonpopupwindow (context);
Myapplication.checklogin (Context, new Appcallback () {
@Override public
void Appcallback (String userid) {
//TODO auto-generated method stub
Dialogutils.dismisscommonpopupwindow ();
Intent opencameraintent = new Intent (context,captureactivity.class);//zing Framework's Class
Startactivityforresult ( opencameraintent,0);
}
);
Break

Then the scan will return the results of the scan in Onactivityresult

@Override public void Onactivityresult (int requestcode, int resultcode, Intent data) {Super.onactivityresult (requestcod

E, 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 (+);
To the tangent string judge//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 an HTML link to a direct jump browser, such as apk downloads Intent Intent =new (); Intent (
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 not find the sweep!!
, 0). Show (); }
}
}

Then jump to the Confirm login interface:

Click to determine the parameters:

@Override
protected void Baseonclick (View v) {
switch (V.getid ()) {case
R.id.tv_qr_login:
// Toast.maketext (qrlogin.this, login, 0). Show ();
Dialogutils.showcommonpopupwindow (qrlogin.this);
Linkedhashmap get_checkqrcodelogin = new Linkedhashmap ();
Get_checkqrcodelogin.put (Key, Myapplication.getuserstate (Loginkey))//Android fixed to 1
get_checkqrcodelogin.put ( SessionID, SessionID)//Android fixed to 1
httpmanager.getcheckqrcodelogin (Get_checkqrcodelogin, New Netcallback () {
@Override public
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

The above is a small set of Android to introduce two-dimensional code scanning and landing the relevant knowledge of the Web page, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.