A week or so eventually the two-dimensional code generation and scanning function to achieve, finally can ease the breath, from the beginning of the doubts why the different scan the client why sweep out the effect of different? Universal scanner scan out is a download apk, the self-made scanner scan out is the desired effective information, and then analyze the fact that the QR code is simply a record of a simple message, usually a URL, and then make a fuss over the URL! Learned the demand and then started to do two-dimensional code generation, with the open source framework QRCode, and then parse zxing, are standing on the shoulders of predecessors continue to do, I did not delve into the deep aspects of the two-dimensional code of Things, Probably just know that the build is based on a two-dimensional bool array and then draw a pixel dot shape to participate in a square picture, in which three corner with the middle piece is not including the information of the three corners is three small rectangle, is to locate the position, there is a square area in the middle there is no information for the logo, compared to everyone is also more Have seen, now the restaurant, the subway basically have sweeping sweep of the logo, hehe, two-dimensional code has become a universal propaganda means! And then I received this task to solve this problem step by step analysis problem, from the generation of a two-dimensional code image, to batch generation to batch Generation page, and each page to be nested with the corresponding QR code, and then to learn Android, due to the previous not how to touch the Java direction of things , and then a simple two-day look at Android, Android Development has a general understanding and understanding, and then to learn Android and unity of the interaction, and then to make Android plug-ins and other processes, as of tonight will eventually function to achieve, there is nothing to solve the problem, just to do , Brain, everything's ok!.
Next I share the production process, about the generation of two-dimensional code I wrote a tutorial, the results were also criticized, said. NET program ape on your level ... For this netizen, I am indeed very ashamed, my level is limited, write content is indeed more superficial, can not meet you seek advanced technology of the discernment, but I write out is for more than the vast number of people just start learning, hope to give them a little help of getting started! I would like to say that someone outside, do not think that they are too bad to look at the novice or not your high level of people, perhaps he will be more powerful technology than you! In a word, perhaps to Daniel, this two-dimensional code generation and resolution is very easy, but I still insist on down, one is also on their own this week more time a summary, second or the previous sentence, hope and the vast number of people just started learning and progress together, Exchange!
Two-dimensional code generation and interaction can look at the article I wrote before: QR code generates http://blog.csdn.net/dingxiaowei2013/article/details/22925709,Unity and Android interaction/HTTP/ blog.csdn.net/dingxiaowei2013/article/details/24485937. On top of that, then implement the function!
A lot of other wonderful content please follow my Weibo @ Ding small reprint Please specify the Source: http://blog.csdn.net/dingxiaowei2013/article/details/24677795
:
the effect after the phone scan:
Description: Here is the unity interface called Android Java method to jump Android development activity view, and then in Android Java method calls unity back to the Unity interface.
Source CodeUnity:
Using unityengine;using System.collections;public class Newbehaviourscript:monobehaviour { private Androidjavaobject activity; private string result= "http://blog.csdn.net/dingxiaowei2013"; Result is used to receive the return value of the QR code void Start () { Androidjavaclass JC = new Androidjavaclass (" Com.unity3d.player.UnityPlayer "); Activity = JC. Getstatic<androidjavaobject> ("currentactivity"); } void Ongui () { //click on the scan code to call the Android method if (GUI. button (new Rect (SCREEN.WIDTH/2-50, 20, 100, 50), "hit Sweep Code")) { activity. Call ("Show"); } Gui. Label (New Rect (SCREEN.WIDTH/2), result); } This is the method called by Android void GetString (String str) { result = str; }}
Android:
Package Com.example.qr_codescan;import Android.content.intent;import Android.os.bundle;import Android.widget.imageview;import Android.widget.textview;import Com.unity3d.player.unityplayer;import Com.unity3d.player.unityplayeractivity;public class Mainactivity extends Unityplayeractivity {private final static int Scannin_grequest_code = 1;/** * Show scan results */private TextView mtextview;/** * Show scanned picture */private ImageView Mimageview; @Overri deprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);//setcontentview ( R.layout.activity_main);//mtextview = (TextView) Findviewbyid (R.id.result); Mimageview = (ImageView) Findviewbyid (r.id.qrcode_bitmap),//////click the button to jump to the QR code scanning interface, here is Startactivityforresult jump/// /After the scan has been transferred to the interface//button Mbutton = (Button) Findviewbyid (R.id.button1);//mbutton.setonclicklistener (New Onclicklistener () {////@Override//public void OnClick (View v) {//intent Intent = new Intent ();//intent.setclass (Mainactivity.this, Mipcaactivitycapture.class);//intent.sEtflags (Intent.flag_activity_clear_top);//startactivityforresult (Intent, Scannin_grequest_code);//}//});} public void Show () {Intent Intent = new Intent (); Intent.setclass (Mainactivity.this, Mipcaactivitycapture.class); Intent.setflags (Intent.flag_activity_clear_top); Startactivityforresult (Intent, scannin_grequest_code);} @Override protected void Onactivityresult (int requestcode, int resultcode, Intent data) {Super.onactivityresult (Requestcode, ResultCode, data); Switch (requestcode) {case Scannin_grequest_code:if (ResultCode = = RESULT_OK) {Bundle bundle = Data.getextras ();// Displays the contents of the scan//mtextview.settext (bundle.getstring ("result"));//Display//mimageview.setimagebitmap ((BITMAP) Data.getparcelableextra ("bitmap")); Unityplayer.unitysendmessage ("Cube", "GetString", bundle.getstring ("result")); break;} }}
Export plugins:then I exported to plug-in, before a sweep code plugin is Easycodescanner, and then my future network called Aladdin, I also named a sweep code of the Android plugin, for Aladdincodescanner, may continue to complete in the future to join? On the iOS scan code function, intact this plug-in, I This is also deeply easycodescanner torture decided to self-reliance! Before easy to find a sweep code plug-in Easycodescanner, the results found that there will be errors and the key is not to achieve the Android scan code function, the Android part of the method has not been implemented, so also contributed to my own idea of writing plug-ins, today, a relaxed! Time is not early, feel too late to the body a little unbearable, the body is the capital, tomorrow will continue to add Project! Good night!
Project Source code:http://down.51cto.com/data/1156726