DevBytes: Android TV - Using the Leanback library
Wednesday, October 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
DevBytes: Android TV - Using the Leanback library
Friday, October 17, 2014
Thursday, October 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
Google Play services 6.1
Wednesday, October 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.
In order to load image from internet, permission of "android.permission.INTERNET" have to be added in AndroidManifest.xml.
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;
}
@Override
protected Drawable doInBackground(String... params) {
Drawable drawable = null;
URL sourceURL;
try {
sourceURL = new URL(params[0]);
URLConnection urlConnection = sourceURL.openConnection();
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
BufferedInputStream bufferedInputStream = new BufferedInputStream(
inputStream);
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
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return drawable;
}
@Override
protected void onPostExecute(Drawable result) {
final Drawable taskDrawable = result;
if (taskDrawable != null) {
taskTextView.setText(Html.fromHtml(taskHtmlString,
new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
return taskDrawable;
}
}, null));
}
}
}
TextView htmlTextViewRemote;
String htmlStringRemote = "Image load from internet"
+ "<img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAeWBgpuPNDBWHI_BjulvcfIEnInSoFM5HpcWSTjr8sPCPzoI3QQUvEUoVafvAJwpW3-cOpcJndM-96hEs-Pzxfpe3r8xYDZgDpsSUO7hyphenhyphenn9wYZT6luUqKztUKFA2nuL5dZ0HWVEZUEotJ/s400/AndroidHtmlTextView_multi_images.png'>";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
htmlTextViewRemote = new TextView(this);
setContentView(htmlTextViewRemote);
htmlTextViewRemote.setText(Html.fromHtml(htmlStringRemote,
new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
Toast.makeText(getApplicationContext(), source,
Toast.LENGTH_LONG).show();
HttpGetDrawableTask httpGetDrawableTask = new HttpGetDrawableTask(
htmlTextViewRemote, htmlStringRemote);
httpGetDrawableTask.execute(source);
return null;
}
}, null));
htmlTextViewRemote.setMovementMethod(LinkMovementMethod.getInstance());
}
}
In order to load image from internet, permission of "android.permission.INTERNET" have to be added in AndroidManifest.xml.
Monday, September 22, 2014
Android graphics performance tips
Animations can be used for good or evil. They can either create rich and compelling experiences that help users understand and use the application, or they can demonstrate just how truly awful the performance of your application is as they stutter and jank all over the screen. "Turn it off! Turn it off!" your users will scream. But there's a better way. Graphics performance is at the heart of smooth and seamless animations: optimize your rendering performance and you can turn your users on instead of having them turn you off.
Chet Haase is the lead of the Android UI Toolkit team, focusing on UI widgets, graphics, performance, animations, and everything else to help make great Android user interfaces. He enjoys taking a break from his real job occasionally to talk about Android at events like this one. His scribblings about Android and less relevant stuff can be found online at google.com/+ChetHaase and @chethaase.
Saturday, September 20, 2014
App Indexing for Google Search
The App Indexing API provides a way for developers to notify Google about deep links in their native apps and allows the Google app, version 3.6 and above, to drive re-engagement through Google Search query autocompletions, providing fast and easy access to inner pages in apps. The deep links reported using the App Indexing API are also used by Google to index app content and are surfaced in Google Search results.
In this video, product manager Lawrence Chang presents an overview of the new App Indexing API for Android that lets you specify links -- through your app itself -- for App Indexing. It also gives you a way to re-engage users through Google Search App autocompletions. We'll provide step-by-step guidelines for how to get started. Take a few minutes and find out how to increase user engagement using the App Indexing API.
Visit: https://developers.google.com/app-indexing/
Friday, September 12, 2014
Intro To Material Design
These days, UI designers need to be thinking about phones, tablets, laptops, TVs, smartwatches, and beyond. In this DesignByte talk about how Google designers have been working on making cross-platform and multi-screen design easier. We wanted to build a design system that felt at home on every screen, from the smallest watch to the largest TV.
DesignBytes: Intro To Material Design
DesignBytes: Intro To Material Design
