Saturday, April 21, 2012

Ways to underline text

I just spent the last 15 minutes trying to underline text in my TextView!!!

Here is an interesting article I found that helped me out.

Tuesday, March 13, 2012

Scrolling on ListView makes background black

To avoid this problem, set "android:cacheColorHint="@android:color/transparent" on your ListView. E.g.:

<ListView android:id="@+id/main_list_view"

Sunday, February 26, 2012

Whew!! Installing your app on a real device!!!

Been trying to install my app on a real device and OMG what a pain that was!! If you read through Google's documentation here, it all sounds really simple. But in reality, it wasn' least for me. I'm using an HTC Incredible and here are some problems I ran into:
  1.  The USB connector cable was not doing a good job connecting the phone to my laptop.....loose connection. I spent an hour trying to figure out why the device wasn't showing up in my list of devices while browsing. And then, voila, my husband figured that the device wasn't connected! Got past step 1!
  2. Next, I couldn't find the OEM driver for HTC Incredible on HTC's website!!! I thought it would be easy enough to search for the driver and find it, but nope! Finally I found it here.
  3. Had trouble installing the driver because the device wasn't connected!! :) Went around in circles again trying to install the driver!!!
  4. And the last problem...I feel stupid for this......the device software version was 2.2 and my application was at a min level 2.1 :( and that it why it wasn't getting installed!! jeez!! This is what happens when you try to install my app on a real device for the first time ever....distracted as ever watching the Oscars! :)
All is well that ends well folks!!!

Sunday, February 12, 2012

How to open adb shell

ADB - Android Debug Bridge
Use: Command-line tool to communicate with emulator or a connected Android device. 

Open cmd in folder: <android-sdk>\platform-tools
More info about adb can be found here.

Error in eclipse: error generating final archive....

When I tried to run my Android program this morning I saw an error in eclipse:
Error generating final archive: Debug certificate expired on 2/10/12 10:42 PM!

All android applications need to be signed and the default period is 365 days. This error was caused because of an expired certificate...which means I set up my Android project around this time last year!! :)

Navigate to .android folder and delete file: debug.keystore
Go back into your project, clean and rebuild - this will regenerate the file with a new key valid for another 365 days.
You could also generate a key file with custom validity - see this blog post for more info.

After i regenerated the key file, I had errors bringing up the application on my AVD. The error was:
[2012-02-12 14:03:45 - Mayuri] Re-installation failed due to different application signatures.
[2012-02-12 14:03:45 - Mayuri] You must perform a full uninstall of the application. WARNING: This will remove the application data!
[2012-02-12 14:03:45 - Mayuri] Please execute 'adb uninstall com.mayuri' in a shell.
[2012-02-12 14:03:45 - Mayuri] Launch canceled!

Apparently the application has to be uninstalled and re-installed after regenerating the key. I tried opening an adb shell to uninstall the application and that did not work. So I ended up deleting and re-creating the AVD. 
The kinds of things you have to do to get your application to run!!

Tuesday, September 27, 2011

Dimensions for Android icons

I've been thinking about compiling a post to capture all my notes regarding dimensions for Android icons and here it is.....btw, I’m still researching dimensions of the splash screen icon – looks like this is tied a little tightly to the actual device dimensions, will blog about that once I find out.

Rule of Thumb: Given an MDPI, you need to increase the image size by 1.5 times to get an HDPI image, and shrink it by 0.75 times to get a LDPI image.

Launcher Icon: Represents the application on the home screen of the device, used to launch the app.
High-density: 60x60 px
Medium-density: 40x40 px
Low-density: 30x30 px

Application Icon: Icon that represents your application in the Android market.
512x512 px, high-resolution icon

Menu Icons: Icons that are used in menus of the application, like a home icon, settings icon, preferences icon etc.
High-density: 48x48 px
Medium-density: 32x32 px
Low-density: 24x24 px

Tab Icons: Icons representing tabs in the application, separate images are created to represent selected and unselected states of the tab
High-density: 42x42 px
Medium-density: 28x28 px
Low-density: 22x22 px
Detailed info:

Splash Icon: Icon that is displayed while the app is being loaded. This icon typically fills up the whole screen and has to match device dimensions.
High-density: 480x800 px

Medium-density: 320x480 px

Low-density: 240x400 px

Other useful links:

Monday, September 19, 2011

Changing emulator size

Sometimes the emulator looks a little large and you will not even be able to re-size it. One would imagine this to be possible but it's not possible.
To change the size of the emulator, go to
Run > Run Configurations > Target > Additional Emulator Command Line Options (scroll down to see this field) > Enter value like "-scale 0.8" to adjust the size