Feb
16
2012
0

Pro Android Apps Performance Optimization

Today’s Android apps developers are often running into the need to refine, improve and optimize their apps performances. As more complex apps can be created, it is even more important for developers to deal with this critical issue.

Android allows developers to write apps using Java, C or a combination of both with the Android SDK and the Android NDK.Pro Android Apps Performance Optimization reveals how to fine-tune your Android apps, making them more stable and faster. In this book, you’ll learn the following:

  • How to optimize your Java code with the SDK, but also how to write and optimize native code using advanced features of the Android NDK such as using ARM single instruction multiple data (SIMD) instructions (in C or assembly)
  • How to use multithreading in your application, how make best use of memory and how to maximize battery life
  • How to use to some OpenGL optimizations and to Renderscript, a new feature in Android 3.0 (Honeycomb) and expanded in Android 4.0 (Ice Cream Sandwich).

After reading and using this book, you’ll be a better coder and your apps will be better-coded. Better-performing apps mean better reviews and eventually, more money for you as the app developer or your indie shop.

What you’ll learn

  • How to optimize your applications in Java
  • How to optimize your applications using the NDK
  • How to best use memory to maximize performance
  • How to maximize battery life
  • How and when to use multi-threading
  • How to benchmark and profile your code
  • How to optimize OpenGL code and use Renderscript

Who this book is for

Android developers already familiar with Java and Android SDK, who want to go one step further and learn how to maximize performance.

Table of Contents

  1. Optimizing Java code
  2. Getting started with the Android NDK
  3. Using advanced NDK features
  4. Using memory efficiently
  5. Multithreading and synchronization
  6. Benchmarking and profiling your application
  7. Maximizing battery life
  8. OpenGL optimizations
  9. Renderscript

About the Author

Hervé Guihot is a software engineering department manager at a leading fabless semiconductor company for wireless communications and digital multimedia solutions. He has more than 10 years of experience in embedded systems, primarily focused on digital television. His current focus is on Android for ARM-based digital home platforms (televisions, Blu-ray players).


Written by admin in: android, sample code |
Feb
14
2012
0

WindowBuilder Support for Eclipse 4 Parts in Juno

I’m happy to see that WindowBuilder will support Eclipse 4 in the Eclipse Juno release. See Bug Report for details.

WindowBuilder is a great efficiency tool for creating user interfaces and he adaption of Eclipse 4 will be much easier for companies by having such a great tooling available for Eclipse 4 based applications.

Eclipse 4 is getting really stable and is very powerful. Last week I trained 16 developers in Eclipse 4 based on the M5 milestone. While we had a few issues in this training, I was very much impressed how stable the platform already is. All discovered issues have been filled, so I expect that M6 will be rock stable.

Also by using the consistent programming model, it was much easier to explain the concepts. No more remembering how to get a Shell from the different places of the application.

I suggest that people really take a peek. I reworked my Eclipse 4 tutorial based on the training, so you should be able to get an easy start.

flattr this!

Written by admin in: sample code |
Feb
10
2012
0

Implement swiping page effect using GestureDetector and ViewFlipper

Refer to the exercise “Detect swipe using SimpleOnGestureListener” and “Bi-direction ViewFlipper“. It’s easy to implement swiping page effect using GestureDetector and ViewFlipper.

Modify the code of the activity from the last exercise “Bi-direction ViewFlipper“.

package com.exercise.AndroidViewFlipper;

import android.app.Activity;import android.os.Bundle;import android.view.GestureDetector;import android.view.GestureDetector.SimpleOnGestureListener;import android.view.MotionEvent;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.ViewFlipper;

public class AndroidViewFlipperActivity extends Activity {

 ViewFlipper page;

    Animation animFlipInForeward;    Animation animFlipOutForeward;    Animation animFlipInBackward;    Animation animFlipOutBackward;

    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);

        page = (ViewFlipper)findViewById(R.id.flipper);

        animFlipInForeward = AnimationUtils.loadAnimation(this, R.anim.flipin);        animFlipOutForeward = AnimationUtils.loadAnimation(this, R.anim.flipout);        animFlipInBackward = AnimationUtils.loadAnimation(this, R.anim.flipin_reverse);        animFlipOutBackward = AnimationUtils.loadAnimation(this, R.anim.flipout_reverse);

    }

    private void SwipeRight(){     page.setInAnimation(animFlipInBackward);  page.setOutAnimation(animFlipOutBackward);  page.showPrevious();    }

    private void SwipeLeft(){     page.setInAnimation(animFlipInForeward);  page.setOutAnimation(animFlipOutForeward);  page.showNext();    }

    @Override public boolean onTouchEvent(MotionEvent event) {  // TODO Auto-generated method stub     return gestureDetector.onTouchEvent(event); }

 SimpleOnGestureListener simpleOnGestureListener     = new SimpleOnGestureListener(){

  @Override  public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,    float velocityY) {

   float sensitvity = 50;   if((e1.getX() - e2.getX()) > sensitvity){    SwipeLeft();   }else if((e2.getX() - e1.getX()) > sensitvity){    SwipeRight();   }

   return true;  }

    };

    GestureDetector gestureDetector = new GestureDetector(simpleOnGestureListener);}

Modify main.xml to remove buttons.

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >

    <TextView        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/hello" />

    <ViewFlipper        android:id="@+id/flipper"        android:layout_width="fill_parent"        android:layout_height="fill_parent">

        <LinearLayout            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:orientation="vertical">            <ImageView                android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:src="@drawable/ic_launcher"/>        </LinearLayout>

        <LinearLayout            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:orientation="vertical"            android:gravity="center"            android:background="#C0C0C0">            <ImageView                android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:src="@drawable/ic_launcher"/>            <ImageView                android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:src="@drawable/ic_launcher"/>        </LinearLayout>

        <LinearLayout            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:orientation="horizontal"            android:gravity="center"            android:background="#A0A0A0">            <ImageView                android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:src="@drawable/ic_launcher"/>            <ImageView                android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:src="@drawable/ic_launcher"/>        </LinearLayout>

    </ViewFlipper></LinearLayout>

Download the files.


Written by admin in: android, sample code |

AndGPS | Connect Android Phone To GPS Solutions