Oct 29, 2014

Android TV - Using the Leanback library

The LeanBack Support Library makes it easy and fast to build great looking Android TV apps. Ankur Kotwal covers the key components to get you started building apps for Android TV using this library.

DevBytes: Android TV - Using the Leanback library

Oct 9, 2014

Google Play services 6.1

Learn about Google Play services 6.1 in this DevByte from Magnus Hyttsten. Google Play services 6.1 adds Enhanced Ecommerce analytics support from Google Tag Manager and offers new improvements to the Google Drive Android API. With this release, we're also including a refresh of the Google Fit developer preview, so that you can test your fitness apps on any Android device.

Google Play services 6.1

Oct 8, 2014

Html.ImageGetter load image from internet, in AsyncTask

This example code use Html.ImageGetter load image from internet, in AsyncTask, to solve error of android.os.NetworkOnMainThreadException in the old example Html.ImageGetter load image from internet.

package com.example.androidhtmltextview;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {

 public class HttpGetDrawableTask extends AsyncTask<String, Void, Drawable> {

  TextView taskTextView;
  String taskHtmlString;

  HttpGetDrawableTask(TextView v, String s) {
   taskTextView = v;
   taskHtmlString = s;

  protected Drawable doInBackground(String... params) {
   Drawable drawable = null;
   URL sourceURL;
   try {
    sourceURL = new URL(params[0]);
    URLConnection urlConnection = sourceURL.openConnection();
    InputStream inputStream = urlConnection.getInputStream();
    BufferedInputStream bufferedInputStream = new BufferedInputStream(
    Bitmap bm = BitmapFactory.decodeStream(bufferedInputStream);

    // convert Bitmap to Drawable
    drawable = new BitmapDrawable(getResources(), bm);

    drawable.setBounds(0, 0, bm.getWidth(), bm.getHeight());

   } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
   } catch (IOException e) {
    // TODO Auto-generated catch block

   return drawable;

  protected void onPostExecute(Drawable result) {

   final Drawable taskDrawable = result;

   if (taskDrawable != null) {
     new Html.ImageGetter() {

      public Drawable getDrawable(String source) {
       return taskDrawable;
     }, null));



 TextView htmlTextViewRemote;

 String htmlStringRemote = "Image load from internet"
   + "<img src='http://4.bp.blogspot.com/-SfOlvitHIXM/Ui3JNj6aRXI/AAAAAAAABvY/wxblITzn3jk/s400/AndroidHtmlTextView_multi_images.png'>";

 protected void onCreate(Bundle savedInstanceState) {

  htmlTextViewRemote = new TextView(this);

   new Html.ImageGetter() {

    public Drawable getDrawable(String source) {

     Toast.makeText(getApplicationContext(), source,

     HttpGetDrawableTask httpGetDrawableTask = new HttpGetDrawableTask(
       htmlTextViewRemote, htmlStringRemote);

     return null;

   }, null));




In order to load image from internet, permission of "android.permission.INTERNET" have to be added in AndroidManifest.xml.

Infolinks In Text Ads