URL转换成二维码

putString(String key, String value) { SharedPreferences.Editor editor = getSharedPreference(CONFIG).edit(); editor.putString(key, value).apply(); } /** * 获取String的value */ public static String getString(String key, String defValue) { SharedPreferences sharedPreference = getSharedPreference(CONFIG); return sharedPreference.getString(key, defValue); }}复制代码

⑤展示二维码

复制代码
public static void showThreadImage(final Activity mContext, final String text, final ImageView imageView, final int centerPhoto) {        String preContent = SPUtil.getString("share_code_content", "");        if (text.equals(preContent)) {            String preFilePath = SPUtil.getString("share_code_filePath", "");            imageView.setImageBitmap(BitmapFactory.decodeFile(preFilePath));        } else {            SPUtil.putString("share_code_content", text);            final String filePath = getFileRoot(mContext) + File.separator + "qr_" + System.currentTimeMillis() + ".jpg";            SPUtil.putString("share_code_filePath", filePath);            //二维码图片较大时,生成图片、保存文件的时间可能较长,因此放在新线程中            new Thread(new Runnable() {                @Override                public void run() {                    boolean success = QRCodeUtil.createQRImage(text, 800, 800, BitmapFactory.decodeResource(mContext.getResources(), centerPhoto),                            filePath);                    if (success) {                        mContext.runOnUiThread(