android 生成二维码 中间可以添加小logo

来源:互联网 发布:minix3.3.0源码下载 编辑:程序博客网 时间:2024/05/17 01:01

这是我之前项目用到的一个方法  百度到的 


    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点击打开链接

0 0
原创粉丝点击