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

Wednesday, September 10, 2014

ARM Guide to Unity: Enhancing Your Mobile Games

Unity is the most popular game engine on the planet, used to develop games and applications across multiple platforms by over 50% of all developers. The ARM Guide to Unity shows these developers how to get the most out of Unity when developing under the unique challenges of mobile platforms. It includes:
  • Visual quality enhancements for your mobile games and applications
  • Optimizations for both CPU and GPU performance
  • Battery life extension techniques for applications running on ARM® Cortex® CPU and ARM Mali™ GPU-based devices
The ARM Guide to Unity was developed alongside, and based on, an industrial placement student’s experience at ARM.  Joel was tasked with creating a Unity game from scratch on a mobile platform and worked with the internal demo and tools teams to create interesting new effects and ensure the finished application was suitably efficient. The team has collated in this guide all the beneficial hints, tips and techniques which arose over the course of the project which we hope beginner and intermediate developers alike will find useful in future projects.



Download the ARM Guide to Unity, from Mali DEVELOPER CENTER

Wednesday, August 27, 2014

Android example using ScheduledExecutorService

java.util.concurrent.ScheduledExecutorService is an ExecutorService that can schedule commands to run after a given delay, or to execute periodically. This example show how to create a one-shot action using ScheduledExecutorService.



package com.example.androidscheduledexecutorservice;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {

Button buttonStart;

ScheduledExecutorService scheduledExecutorService;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

buttonStart = (Button)findViewById(R.id.start);
buttonStart.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {

Toast.makeText(MainActivity.this,
"Start",
Toast.LENGTH_LONG).show();

scheduledExecutorService = Executors.newScheduledThreadPool(1);

scheduledExecutorService.schedule(new Runnable(){

@Override
public void run() {
MainActivity.this.runOnUiThread(new Runnable(){

@Override
public void run() {
Toast.makeText(MainActivity.this,
"Times-up",
Toast.LENGTH_LONG).show();
}});

}},
5,
TimeUnit.SECONDS);

}

});
}

}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.androidcountdownprogressbar.MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android-coding.blogspot.com" />

<Button
android:id="@+id/start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start" />

</LinearLayout>

Monday, August 25, 2014

android.widget.TextClock example

android.widget.TextClock, Added in API level 17, display the current date and/or time as a formatted string.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.androidcountdownprogressbar.MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android-coding.blogspot.com" />

<TextClock
android:id="@+id/clock"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textStyle="bold"
android:textSize="50sp" />

</LinearLayout>

Saturday, August 23, 2014

Android example to execute threads with ExecutorService

ExecutorService is an Executor that provides methods to manage termination and methods that can produce a Future for tracking progress of one or more asynchronous tasks. This example implement 5 threads to update ProgressBars in background thread. The threads executed by a ExecutorService, with thread pool of 2. Such that only 2 thread is running at any time.


package com.example.androidcountdownprogressbar;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;

public class MainActivity extends ActionBarActivity {

Button buttonStart;
ProgressBar progressBar1, progressBar2,
progressBar3, progressBar4, progressBar5;

CountThread countThread1, countThread2,
countThread3, countThread4, countThread5;

ExecutorService executorService = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

buttonStart = (Button)findViewById(R.id.start);
progressBar1 = (ProgressBar)findViewById(R.id.progressbar1);
progressBar2 = (ProgressBar)findViewById(R.id.progressbar2);
progressBar3 = (ProgressBar)findViewById(R.id.progressbar3);
progressBar4 = (ProgressBar)findViewById(R.id.progressbar4);
progressBar5 = (ProgressBar)findViewById(R.id.progressbar5);

buttonStart.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {
countThread1 = new CountThread(progressBar1);
countThread2 = new CountThread(progressBar2);
countThread3 = new CountThread(progressBar3);
countThread4 = new CountThread(progressBar4);
countThread5 = new CountThread(progressBar5);

executorService = Executors.newFixedThreadPool(2);
executorService.execute(countThread1);
executorService.execute(countThread2);
executorService.execute(countThread3);
executorService.execute(countThread4);
executorService.execute(countThread5);
}});

}

public class CountThread extends Thread{

ProgressBar progressBar;
final int MAX_PROGRESS = 10;
int progress;

CountThread(ProgressBar progressBar){
this.progressBar = progressBar;
progress = MAX_PROGRESS;
}

@Override
public void run() {

for(int i=0; i<MAX_PROGRESS; i++){
progress--;
MainActivity.this.runOnUiThread(new Runnable(){

@Override
public void run() {
progressBar.setProgress(progress);
}});

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}
}

}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.androidcountdownprogressbar.MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android-coding.blogspot.com" />

<ProgressBar
android:id="@+id/progressbar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:progress="0" />
<ProgressBar
android:id="@+id/progressbar2"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:progress="0" />
<ProgressBar
android:id="@+id/progressbar3"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:progress="0" />
<ProgressBar
android:id="@+id/progressbar4"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:progress="0" />
<ProgressBar
android:id="@+id/progressbar5"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:progress="0" />
<Button
android:id="@+id/start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start" />

</LinearLayout>