您的位置:首页 > 移动开发

Android a手机扫描b手机二维码,a手机跳转到本App评分

2017-01-01 10:55 330 查看
 private Bitmap encodeAsBitmap() throws WriterException {

        Hashtable hints = new Hashtable();

        hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");

        BitMatrix result;

        try {

            result = new MultiFormatWriter().encode("http://market://details?id="+getPackageName(),

                    BarcodeFormat.QR_CODE, 250, 250, hints);

        } catch (IllegalArgumentException iae) {

            // Unsupported format

            return null;

        }

        int w = result.getWidth();

        int h = result.getHeight();

        int[] pixels = new int[w * h];

        for (int y = 0; y < h; y++) {

            int offset = y * w;

            for (int x = 0; x < w; x++) {

                pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.WHITE;

            }

        }

        Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);

        bitmap.setPixels(pixels, 0, 250, 0, 0, w, h);

        return bitmap;

    }

上面代码 生成二维码 跳转失败

case R.id.give_me_score_relative:

Uri uri = Uri.parse("market://details?id="+getPackageName());

Intent intent = new Intent(Intent.ACTION_VIEW,uri);

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(intent);

break;

如果是点击跳转就没问题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: