views:

282

answers:

8

What is your Emulator feature that you could not work without?

Which unknown great shortcut, console command or startup option is there that you discovered and you think has to be also known by all other Android devs?

Share your Emulator wisdom with us.

+6  A: 

You can enable/disable the Emulator Network with: F8

Great for testing service interruptions while your app is connected to some web based service. It allows very fast disabling just at the moment a download or a webservice started.

Janusz
That doesn't work always for me. Don't know why. The better way in that cases to turn on airplane mode :)
Mur Votema
Yeah but airplaine mode is not instantanious, if the F8 thing is working it is the fastest way to do something like,: Oh I wonder what happens if this request is started, and then the connection is dropped.
Janusz
+6  A: 

You can rotate it ;) ctrl + F11

Mur Votema
I always rotate it by pressing 7 on the keypad (with numlock disabled)
Felix
The full list of keypad/keyboard shortcuts is here: http://developer.android.com/guide/developing/tools/emulator.html#controlling
Dave MacLean
+5  A: 

F6 - start track ball emulation

When working with high resolution screen, one can reduce the size of the emulator to make it fit better on PC screen: AVD Manager - Start - check "Scale display to real size" and set Screen size to a suitable value (6 works for me)

Asahi
+7  A: 

Not exactly an emulator feature but related.

When using Eclipse for Android development, the debug certificate that is automatically created only lasts 1 year. When it expires, it's a pain to have to delete all your development .apk files, because the new certificate doesn't match so you can't upgrade them in all your AVDs. You have to get another development MAP-API key as well. The published recommendation is to simply delete the debug.keystore file and Eclipse (ADT really) will create a new one for you, again with a 1 year expiration. But you can create your own debug certificate in debug.keystore with whatever expiration you want. Do this in the .android folder under your HOME directory:

keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 14000

ADT sets the first and last name on the certificate as "Android Debug", the organizational unit as "Android" and the two-letter country code as "US". You can leave the organization, city, and state values as "Unknown".

Dave MacLean
Wow that is really helpfull and good to know. I'm not developing for Android. Have to check how long my debug certificates will last.
Janusz
+4  A: 

Using DDMS to debug a service which has no Activity.

Assuming you've written a service in its own apk which to be used by another application, then it's not possible to set break points in the service app's code and have them trigger when the other app runs and invokes the service.

If, however, you go to the DDMS perspective, find the service's thread and highlight it, then click the bug icon in the DDMS, breakpoints are triggered.

This answers one of my own (unanswered) questions.

NickT
+4  A: 

Demonstrate an android app from a USB stick

Assuming you want to show a friend/client your app and their machine has no Android SDK, Eclipse or even an uptodate JRE, you can put all you need on a USB drive without affecting your development environment.

Make an 'androiddem' folder on the stick, copy a minimal sdk (don't need the docs or samples) with the platforms you need and a Java runtime to their own folders.

Open a DOS box from the root of the USB drive and set a local environment variable ANDROID_SDK_HOME to the root of the drive. (This env variable is a bit of misnomer if you use Eclipse as it doesn't need it and picks up the SDL location from the general Android preferences). It does control where the AVDs get created though, so once you've set it to h:\ (say), you can drop down to to the tools directory on the stick and create AVDs in the normal way - they will end up in .android on the stick.

If you copy the .apks that you want (make sure they were signed with a release key) to the stick, then from another DOS box(with the ANDROID_SDK_HOME set as before you can use the adb commands to install the apks to the AVDs you made.

All you have to do then is take the stick to the target machine, open a DOS box again, set the ANDROID_SDK_HOME, prepend the JRE to the path and run the emulator nominating the target AVD.

You can simplify the process by creating batch files on the stick to set env variables and paths.

NickT
Nice I have to try to create a Stick that I can leave with a client that enables them to start an emulator. They could get the newest APK from my Webspace via the Emulator Browser.
Janusz
+3  A: 

Keep the emulator open while developing to avoid the boot time.

(Source: Pragmatic Programmer's Hello Android book - Ha, I just read this yesterday.)

Moshe
Yes basic tip but maybe the most time consuming error. Closing the emulator after testing an app will make you loose two minutes each time you start your app.
Janusz
@Janusz - Yep, in fact, my first mistake was to keep closing the emulator each time I wanted to close the test app. My mistake. I learned the hard way.
Moshe