Android Development: Casino Strategy v1.0

Maybe it's because I'm listening to The Lean Startup, but I decided to create a minimum viable product (MVP) as the first version of my app. I went with the simplest idea that still had some value, displaying a Blackjack strategy card for use in a casino. The goal was to quickly get a feel for Java, Eclipse, and the Android API.

After running through the Hello, World tutorial, I created a simple app with one Activity. The layout was just an ImageView that displayed a png file I had on my computer.

public void onCreate(Bundle savedInstanceState) {
  mImage = (ImageView) findViewById(;

Next, I created a strategy card in Excel and used Paint.NET to save it as a png file. I followed the first part of the Notepad tutorial to learn how to insert a menu. It's used to display an AlertDialog with a key showing how to read the card.

public static final int KEY_ID = Menu.FIRST;

public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case KEY_ID:
      return true;
  return super.onOptionsItemSelected(item);

private void displayKey() {
  if (mKey == null) {
    mKey = new AlertDialog.Builder(this);builder.setMessage(getKeyMessageText()).setPositiveButton("Close",
      new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {

At about this point, I decided to install git to start version controlling my app so I could quickly revert any changes I didn't like. I also moved my Eclipse workspace to my Dropbox folder both for backup and so I could work on it from multiple computers.

Now that my code was protected, I added another AlertDialog with a list to allow the user to select different strategy cards. The method below is called from a new case in onOptionItemSelected().

private void displayGameTypes() {
  if (mGameTypes == null) {
    final CharSequence[] gameTypes = { "Stands on 17", "Hits on 17" };
    mGameTypes = new AlertDialog.Builder(this);
    builder.setItems(gameTypes, new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int item) {
        switch (item) {
          case 0:
          case 1:

I wanted to be able to swipe between the cards, but instead of adding that extra scope to my MVP, I made a note to investigate it for v2.0. After creating the second card with Excel/Paint.NET, I was ready to publish!

Stay up to date

Get notified when I publish. Unsubscribe at any time.