get Qrcode Of Application - Android Graphics

Android examples for Graphics:Qrcode

Description

get Qrcode Of Application

Demo Code


//package com.java2s;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import android.content.Context;
import android.graphics.drawable.Drawable;

public class Main {
    public static Drawable getQrcodeOfApplication(Context context) {
        try {//from  w  w  w. j  a v a 2s .  c  o  m
            return Drawable
                    .createFromStream(
                            (InputStream) new URL(
                                    "https://chart.googleapis.com/chart?cht=qr&chs=256x256&chl=market://details?id="
                                            + context.getPackageName())
                                    .getContent(), "src");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related Tutorials