published: December 12th, 2008

Listing Androids drawable Resources

Wrote this real quick Android ListActivity to display the Resources from the android.R.drawable.  Not very pretty, but I just wanted something to display the images and show the associated Resource id.  Sorry in advance for any wacky formatting issues due to cutting and pasting from Eclipse into the WordPress editor.

(more…)

published: December 11th, 2008

SQLite SUM and IN commands for Android

public int calculateTotalSalaryForEmployees( long[] departmentIds )
{
    int total = 0;
    // create a list of ids to use in the IN statement
    // Arrays.toString creates String which looks like [1,2,3]
    String deptlist = Arrays.toString( departmentIds );

    // remove the enclosing brackets from id list
    String inClause = deptlist.substring( 1, deptlist.length() - 1 );
    String sql = "select sum(salary) from employees where department_id " +
        "in (" + inClause + ")";

    Cursor c = mDb.rawQuery( sql, null );
    // move to the first row of the cursor
    c.moveToFirst();
    total = c.getInt(0);
    c.close();

    return total;
}

Trying something new out here. As I’m programming I find many little hints and tips that I want to remember or share. Not the longer more in-depth posts I’ve been trying out with the subjects on Android HTTP and Ruby on Rails, but little quick things to put into ones toolbox.

So here’s the first one, a little method to retrieve the sum of all the salaries of employees within a department.  It utilizes the SQL SUM and IN commands.  It was surprisingly difficult to find the exact way to perform these command, but surprisingly obvious and easy once I figured it out.  Just the types of little tools I don’t want to loose.

published: December 8th, 2008

Hide the Title bar in an Android View by using the Window Class

Had to hunt around for this in the Android documentation so I thought I’d mention it in case anyone else could utilize it.  In my new shopping list application I want to display dynamic information in the title bar and didn’t want to display the default title bar.  I knew it could be done from looking at the application view screen on the Android Market. There is a flag in the Window class to hide the title bar, and it’s placed in the onCreate method of an Activity.

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    ...

I was expecting to find a setter method in either the Activity or the View class.  After hiding the title bar, I simply added a TableLayout to the top of my View to display the information.

I’m not exactly sure what the relationship is of the Window to the View or the Activity other then what is already documented in the Window API and Google’s glossary for Android, maybe I’ll get some time in the future to poke around a bit more.

published: December 6th, 2008

Android SDK 1.0 release 2 available

Dan Morrill snuck out a post late yesterday on the Android Developers blog stating that Android SDK 2.0 is now available.  Apparently no new features, but fixes for some bugs.  Dan also stated that a G1 developers device is now available.  So if you aren’t in an area where the HTC G1 has been made available you now have a means to test your applications.

published: December 2nd, 2008

New version of Jumpy posted to Android Market

I finished another version of Jumpy last night.  I added in a small feature to detect when there are no more moves available, signaling the end of a game.  Not a huge change, but I thought it was worth putting it out on the market.  This is an important ability for future features which, I hope, will extend the game for users how have already solved the puzzle.

published: November 25th, 2008

Android - Ruby on Rails Project Part 3: Using Android Cursors

In this post, I show how I removed the Project POJOs and marshal the XML data directly into the Android database.  Usually I have a layer of objects defining the model API and encapsulating the database, but with Android, Google has pre-written those objects in the form of cursor adapters.  Furthermore, there is little chance on a platform like Android that a dramatic change in the back end model will occur, as opposed to a larger less constrained application where a MySQL db is swapped with a Oracle database, then swapped with a distributed data system.

(more…)

published: November 21st, 2008

Jumpy reviewed on Android Guys!

Wow, I kinda feel like a celebrity :).  I had no clue that Jumpy would get an official review!  Thanks to Android Guys, Jumpy has now been critiqued.  Hopefully I’ll be able to find the time soon to make some improvements and get a version ?.?.? out the door.

published: November 11th, 2008

Android - Ruby on Rails Project Part 2: Some simple SAX parsing

Must….Finish…..Post…

I’ve been sitting on this post for awhile.  I had the code written weeks ago, but I’ve been procrastinating about getting the surrounding text completed.  As I’ve been trying to get the text written I’ve come up with other ideas, and instead of continually modify the code, I’ll present one solution here, and in my next post I will address one that eliminates the Project POJO.

The goal of this post is to take the nodes of the retrieved XML file from our REST call that I discussed in my early blog post and convert it into an array of concrete objects holding the XML node values as attributes.

This will be done by the following classes and interfaces

1) IObjectTranslator
2) Project
3) AbstractTranslator
3) SaxParser

The methodology discussed is one of many ways to extract objects from an XML document.  And just as a disclaimer to myself, this won’t be any ground breaking stuff, and being a Java programmer who usually has at least desktop processor and memory at his disposal, this may not be the most efficient solution for parsing an XML document on a mobile device, but nested if’s upon nest if’s are a pain to maintain in my most humble of opinions.  Okay, enough futzing around.

(more…)

published: November 3rd, 2008

Next version of Jumpy published to Android Market

Just a quick note that version 1.1.0 of Jumpy is available on the Android Market.  The features I added include:

  1. An undo option allowing the player to move back the most recent move.
  2. Redo Board allows the player to redo the most recently played board.
  3. A setting has been added allowing the player to choose the first piece removed from the board.

I uploaded it to the Android Market over the weekend, but because of a bug in the market software it cleared out the total number of downloads and the rating Jumpy received to that point.  Currently it has been re-downloaded 1304 times and has a rating of 3 1/2 stars.  Thanks everyone who has tried out the new version.

I also have another application or two I’m working on.  The next one I plan to concentrate on is a mobile shopping list with a couple extra features that other shopping lists I’ve seen are missing.  And since I don’t like to waste to much time initially thinking of a name I’ll go with…ahh…hmmm… Honest Shopper.

published: October 28th, 2008

Thanks for all the input for Jumpy ver 1.0.0

Today has been an awesome day for me!  For the first time I’ve taken an idea (albeit a very simple one), written a program, deployed it for others to use (although not all in one day), and enjoyed as users gave feed back to my work, good and bad.

(more…)