set Qrcode Of Application - Android Graphics

Android examples for Graphics:Qrcode

Description

set 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;

import android.widget.ImageView;

public class Main {
    public static void setQrcodeOfApplication(Context context,
            ImageView view) {/*from  w  w  w .  j a  v a  2s .  c o m*/
        try {
            view.setImageDrawable(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();
        }
    }
}

Related Tutorials