ZXING条码扫描源码

MrLee11月前6570
package com.app.zxing;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
	private final static int SCANNIN_GREQUEST_CODE = 1;
	EditText et_device_number;
	Button btn_submit;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	
    	setContentView(R.layout.loading);
    	
    	
    	et_device_number=(EditText)findViewById(R.id.et_device_number);
    	btn_submit=(Button)findViewById(R.id.btn_submit);
    	
    	btn_submit.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View arg0) {
				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();
				//显示扫描到的内容
				et_device_number.setText(bundle.getString("result"));
			}
			break;
		}
    }	
}

20161102153455


源码:zxingdemo

本文链接:http://www.ithtw.com/thread-11177.htm
转载请注明:11月前 于 IT十万个为什么 发表
推荐阅读
最新回复 (0)
回复
登录发表 or 还没有账号?去注册