performance

ProgressBar updating using Message Handler

SDK Version: 
M3

You're going to learn how to make a progressbar, which gives you a feedback what's going on in the background.

Let say you have a LoadingScreen activity (loadingscreen.xml layout), and a Main activity (main.xml).

You'd like to do some job in the Main activity, and update the progressbar status at the same time. To do this, we are going to use Messages. Although, you can update you're progressbar by sending the progressbar instance itself to your Main activity, but that's obviously not the prettiest solution.

What we going to do is:

1. Declaring a progressbar instance in LoadingScreen Activity:

So in your LoadingScreen.java, after Oncreate(), you should add something like this line to your codeline: (don't forget to add a progressbar to your layout first!)

  1.   ProgressBar pb = (ProgressBar)findViewById(R.id.ProgressBar01);

2. Setting up a Handler to handle Messages from outside:

Mastering Android Widget Development - Part1

SDK Version: 
M3

In Days to Xmas tutorial you can see a simple widget example, which demonstrates what widgets are used for, and shows an example how they can work. Now I begin a series of tutorials to fully explain the working of widgets.
We will also create a sample application, during the tutorials, which will show a countdown to a given date in secunds, but things that are not required for this specific example applications will be explained too.

For this first part I will go though mainly the parts described in http://developer.android.com/guide/topics/appwidgets/index.html but I try to give more explanation and advice.

Some general thoughts at first:

Introducing the Android Emulator, managing Android Virtual Devices (AVD)

SDK Version: 
M3
The emulator available in the Android SDK is not just a tool that allows you to easily test applications without having to install it to a real device, or even having one. With the proper configuration it is possible to test situations which are hardly reproduced on a physical one.
 
After installing the android plugin and SDK in eclipse an icon is automatically placed on the toolbar to quickly access the Android SDK and AVD (Android Virtual Device) manager.
 
eclipse

You can create multiple AVDs with different parameters:

sdk

How to set up Eclipse with Android SDK on Ubuntu linux 9.04/9.10 (updated)

SDK Version: 
M3

In my first tutorial i will show you how to set up Eclipse 3.5 with Android Development Tools (ADT) on Ubuntu 9.04.

Before we can install the Android SDK, we must install Java. First we open a new terminal window (Applications > Accessories > Terminal).

To install Java, type:

sudo apt-get install sun-java6-bin 

If you are on a x86_64 system, you also must install ia32-libs:
 

sudo apt-get install ia32-libs

For Ubuntu 9.10 users:

In my first tutorial i will show you how to set up Eclipse 3.5 with Android Development Tools (ADT) on Ubuntu 9.04.

Before we can install the Android SDK, we must install Java. First we open a new terminal window (Applications > Accessories > Terminal).

To install Java, type:

sudo apt-get install sun-java6-bin 

If you are on a x86_64 system, you also must install ia32-libs:
 

sudo apt-get install ia32-libs

For Ubuntu 9.10 users:

Install eclipse from apt-sources, so open a terminal, then:

sudo apt-get install eclipse

How to debug a Service?

SDK Version: 
M3

In this tutorial we will show you how you can easily debug a service.


debugIntroduction

When you start a project with a service in it in debug mode, and you placed a breakpoint in a method of the service, the debugger will not stop. 

Solution

The solution that works in almost all situation is to wait declaratively in the code for the debugger to attach. To do this, you have to make a call to:

  1. android.os.Debug.waitForDebugger();

The breakpoint can be inserted at any line after this call. 

As a complete example, the SoftKeyboard tutorial is enhanced with the call above:

  1. public class SoftKeyboard extends InputMethodService
  2.         implements KeyboardView.OnKeyboardActionListener {
  3.        
  4.     @Override
  5.         public void onConfigurationChanged(Configuration newConfig) {

Using threads and ProgressDialog

SDK Version: 
M5

This example shows you how to properly use a thread to do work while displaying an indeterminate ProgressDialog.

Syndicate content