Tuesday, May 18, 2010

Android screen capture

I found out how to use Eclipse to grab a screen capture of my android device. REALLY cool. No market app necessary.

  1. Connect your phone to your computer
  2. Open Eclipse
  3. Click on the DDMS Perspective
  4. Look at the Devices view
  5. Click on your phone
  6. Use the Menu Icon to Select > Screen Capture.


  7. You'll see something like this:



  8. Save your screen capture

Friday, May 14, 2010

Android custom buttons

http://stackoverflow.com/questions/1521640/standard-android-button-with-a-different-color


Put something like the following code in a file named custom_button.xml and then set background="@drawable/custom_button" in your button view:
xml version="1.0" encoding="utf-8"?>


xmlns:android="http://schemas.android.com/apk/res/android">

android:state_pressed="true" >


android:startColor="@color/yellow1"
android:endColor="@color/yellow2"
android:angle="270" />

android:width="3dp"
color="@color/grey05" />

android:radius="3dp" />

android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />



android:state_focused="true" >


android:endColor="@color/orange4"
android:startColor="@color/orange5"
android:angle="270" />

android:width="3dp"
color="@color/grey05" />

android:radius="3dp" />

android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />






android:endColor="@color/blue2"
android:startColor="@color/blue25"
android:angle="270" />

android:width="3dp"
color="@color/grey05" />

android:radius="3dp" />

android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />



Thursday, May 13, 2010

How to Add a repeating background graphic on an Android Application

This took me a little to find the right resource to make this happen. So here it is:

http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html

The author shows how to add a style for a repeating background towards the end. The style isn't picked up immediately using the Eclipse xml editor but once the application starts it's there.

Monday, May 10, 2010

Associating a Private Key using Android ConnectBot

https://isa.its.yale.edu/confluence/display/UNIXSYSPUB/Android+SSH+App+-+ConnectBot

Adding your OpenSSH Private Key

Connect your droid to your pc via USB. Copy over your ssh private key, and you can use ConnectBot's "Manage Pubkeys" tool to import it. I tried it with an OpenSSH private key, and it worked flawlessly. Importing a SSH.com key is possible, using PuTTY's keygen tool to convert the private key first.

Setting Up A Connection

Once you have your private key in ConnectBot, you can set up a connection. You can edit that connection once you've created it by long-tapping the host listing and choosing "Edit Host". When you edit the host, you can associate a private key with it, set the SSH Agent Forwarding to on, and change the font size (VITAL -- I find font size 16 to be very readable...size 10 not so much.)

Saturday, May 8, 2010

Eclipse Debug with HTC Incredible Droid

I just got my new HTC Incredible phone yesterday and wanted to test some local android applications on it. The Incredible is so new that the standard usb device installer recommended by the android dev website isn't enough to get started. I found this blog post from someone who figured it out and sure enough, my incredible was recognized after following his steps.

Thursday, May 6, 2010

Android - Writing to the log file

Very simple.

Add a log such as this:
Log.i("Main","Starting the IBM Cloudroid application");

This first string is the "tag" you want to give your log message. And the second string is your message.

To view the log, start you application, in Eclipse is switch to the DDMS perspective








to see the LogCat view:



Wednesday, May 5, 2010

Android - Opening a new "window" activity

I'm playing around with some android development for work and found this post helpful as a newbee.


Basically all you have to do is:

1. Add the following to your AndroidManifest.xml file:

2. Create the NewActivity class

3. On the button press or whenever you want to see the new activity launched call something like this:

Intent i = new Intent(MainActivity.this, NewActivity.class);
startActivity(i);

That's it!!