platform specials

How to disable a button on an appwidget?

SDK Version: 
M3

Would you like to disable a button on an appwidget?
As far as I know it can not be done, since the appwiget UI manipulation is limited by the methods of the RemoteViews class.

But if you insist to do that there is a way to make it look like the button were disabled!

RemoteViews can't manipulate a buttons enabled/disabled state, but it can modify its visibility. So the trick is to have two buttons, the real one, and an other which is designed to look like the real one in disabled state, and change witch one is visible.

Lets see a simple example:
We want to have two buttons on the widget, a stop and a start button in order to stop and start some kind of functionality. Once we have started it, we can not start it agin, until we stopped it and vica versa, so we want to disable the button which can not be used right now.

The XML definition of the buttons can be like this:

  1. <Button android:id="@+id/startbutton" android:text="Start" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
  2. <Button android:id="@+id/startbutton_disabled" android:text="Start" android:clickable="false" android:textColor="#999999" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

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 set location on emulator

SDK Version: 
M3

emulatorYou have two options if you would like to set the location on the emulator. For both options, you start with starting the emulator first.

Option 1: using DDMS

  • go to your android/tools directory, and launch the DDMS tool
  • select the Emulator Control Tab
  • fill the Location Controls fields with the longitude and latitude values
  • press the Send button

Option 2: using telnet

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.

MusicDroid - Audio Player Part II

SDK Version: 
M3

In part 2 of the MusicDroid media player tutorial series, we will move the MediaPlayer object into a remote service so that you can use the rest of the phone while playing your music. We will setup this service so that it will be simple to add the controls in part 3 for Pause, Stop, Skip forward, Skip back, etc. This service will also provide a marquee notification each time a new song starts, and a notification icon for play/pause status.

Syndicate content