
⑤展示二維碼

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(