2013년 1월 3일 목요일

Google Charts API를 이용한 QRCode 생성

private Bitmap makeQRCode(){
  String input = "http://m.naver.com";
  URL url;

  try{
    url = new URL("http://chart.apis.google.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl=" 
    +  URLEncoder.encode(input, "UTF-8"));
    URLConnection conn = url.openConnection();
    conn.connect();
    InputStream is = conn.getInputStream();
    BufferedInputStream bis = new BufferedInputStream(is);
    Bitmap bmp = BitmapFactory.decodeStream(bis);
    bis.close();
    is.close();
  
    return bmp;
  }catch(Exception e){
    e.printStackTrace();
    return null;
  }
}
[Google chart api]

cht=qr
chs=<size>
chl=<text to encode>
choe=<output encoding>

댓글 없음:

댓글 쓰기