In-app Billing in an Android Space War Game

I am going to write a series of articles about how to implement in-app billing for an Android game app. I will get that started by telling you something about the game app I am working on and how in-app purchases tie in to upgrades within the game.

Coin purchase screenshot

The name of the app is “Starship”, but that’s likely to change during beta test. Starship is a turn-based, single player, space war game. It is available for Android phones and tablets. The game begins with you in training. You take on training missions that allow you to advance through the ranks of Weapons Officer, Navigator, Commander, and finally, Captain. Upon promotion to Captain, you command a very powerful starship. Your mission is to find and destroy alien starships that have invaded the galaxy. To end the threat completely, you must find the alien home world and destroy it. A screenshot from the game is shown below.


As you play the game and destroy alien ships, you earn gold coins. The coins can be used to purchase items that improve your capabilities. In the current version of the game, there are four upgrades that you can purchase:

  • Long Range Move Equipment – allows you to jump to a distant quadrant in one move. Crystals power this equipment.
  • Mining Equipment – allows you to mine crystals from planets.
  • Extra Starbases – give you more places where you can resupply and make repairs
  • Extra Mission Time – gives you more time to complete missions

None of these upgrades are made with in-app purchases. All it takes to upgrade is gold. There are, however, two ways to get gold coins: (1) you can earn gold coins within the game by going on missions, destroying the enemy ships, and moving up levels; or (2) you can go to the Coins store screen and purchase coins there.

The figures below show what a complete transaction looks like within the game. You start on the Coins screen, select an item to purchase, enter your password, and then wait for the order to be fulfilled. The white popup boxes are being done by code in the Google Play services library.





Once the receipt makes it back into the game, notice that the coin total in the upper right of the game screen increases by the amount of coins you purchased.


After the purchase, the player uses the Upgrades screen to purchase one of the upgrades.


Model for In-App Purchases

In some game apps, you have to make an in-app purchase if you want the extra equipment or powers. That is not the case in this game.

In Starship, you are not required to make in-app purchases to get ahead in the game. If you earn the coins playing the game, use them to make upgrades. If you would like to get those items a little faster, you spend real money to get in-game money. Of course, the other reason to make a purchase is because you enjoy the game and would like to send a little money to the developers as a way of thanking them.

Next Articles

This note is not a how-to article. What I usually do on this blog is provide working demo programs with source code. That’s what you will see in the next set of articles about in-app billing and purchases.

Topics for the upcoming articles include:

  • Suggestions on how to get started with the TrivialDrive demo program.
  • Adapting the TriviaDrive demo to your own application.
  • Tips and suggestions for testing in-app billing.
  • Tutorials and suggestions for building your own Coins and Upgrades screen.
    (Some of this is already available. See below.)
  • Different ways to invite players to upgrade.


New Turn-Based Space War App – article about the Starship game app. Read this if you want more information about the game or would like to be part of the test community.

Update on Starship game – a short note about some new features in the game.

Android Fragment for an Item in a Store – article about a demo app that uses Android fragments to displays items in a list. The same fragment is used in the Starship app for the Coins screen and the Upgrades screen.

Examples of Store Item Activities in Android – a follow-up article to the fragment article.

Google I/O 2012 – Monetizing Android Apps – a talk from Google I/O 2012. It covers the different ways you should consider for making money from your apps.




About Bill Lahti

Bill Lahti is a software engineer building mobile applications and knowledge management solutions. Two of his interests are writing for this blog and building Android apps, with strategy games being an area of particular interest.
This entry was posted in Android, Game Design and tagged , , , , . Bookmark the permalink.

3 Responses to In-app Billing in an Android Space War Game

  1. Pingback: How to Add In-app Billing to an Android Game – Part 1 | More Is Not Always Better

  2. sush says:

    can you post a easy way to implement in app billing?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s