这是我之前项目用到的一个方法 百度到的
imgCode = (ImageView) findViewById(R.id.img_code); File path1 = new File(Environment.getExternalStorageDirectory().getPath()+"/Json"); if (!path1.exists()) { //若不存在,创建目录 path1.mkdirs(); } //创建的二维码地址 filePath = Environment.getExternalStorageDirectory().getPath() + "/Json/" + "code_json.jpg"; new Thread(runAddEwmImg).start(); } Runnable runAddEwmImg = new Runnable() { @Override public void run() { // BitmapFactory.decodeResource(MainActivity.this.getResources(), R.mipmap.ic_launcher) 中间的logo图, //中间不添加图片 直接写null boolean isTF = QRCodeUtil.createQRImage("这里写入你需要的网址或者验证码", 400, 400, BitmapFactory.decodeResource(MainActivity.this.getResources(), R.mipmap.ic_launcher), filePath); if (isTF) { handler.sendEmptyMessage(5); } } }; Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); imgCode.setImageBitmap(BitmapFactory.decodeFile(filePath)); } };demo地址:http://download.csdn.net/detail/u011345545/9660246 点击打开链接