My new android app

Well, it’s not exactly what I expected to create, but one of my goals this year was to get at least two Android apps into the market(s): one free and one paid. Those goals are now accomplished.

My free app has been in the market(s) for a while, and has actually gotten a recent update: Mono Stock Portfolio, which is totally free (and no ads), and was really just a way for me to help learn (and teach) the Mono for Android tool. According to Google, this app actually has a surprisingly large user base: 1080 total installs, and 393 active installs. And I’ve gotten several e-mails from users asking for more features!

The other app, I just threw together this weekend in a sudden fit of whimsy, inspired in no small part by this commercial:

The app is “Yeah Dog!“, which I started creating with Mono for Android, but soon realized that the 5mb+ overhead just didn’t make sense for this app. So I rewrote it, painstakingly, in Java, which wasn’t as unpleasant as I thought it might’ve been (but unpleasant nonetheless). This app will set you back 99 American cents, and is also ad-free.

In the process of creating and publishing Yeah Dog!, I came to find out that I was beaten to market! First, GEICO actually released their own “BroStache” app some time ago, but I discovered that there is a secret “Yeah Dawg” feature in that app. Secondly, some other rascal created his own YeahDawg app (albeit an inferior one!) and published a mere two days before me.

Oh well. Such is the harsh reality of free markets. But in any case, I believe I have enriched myself as a developer, speaker, and businessman throughout the process of creating, publishing, and maintaining these apps, so that alone makes it worth it.

Monodroid – Passing information to an activity

On my Monodroid app, I have a list of portfolios. When a user clicks on that portfolio, they should be sent to a child activity to see information about the portfolio they clicked on. I already blogged about how to open a new activity, so now I’m going to blog about how I pass information to that activity (for instance, the name of the portfolio). Android calls this information “extras”.

I have a ListView with an ItemClick event already wired up. Here is the ItemClick event:

Again, the ClassName property is just something I cooked up to hold a string value (see above linked blog post). Notice the main difference is that I’m calling the “PutExtra” property on the intent. This is pretty much just a way to box information up and send it to the next activity. The “Extra_PortfolioID” property is, again, just a string, and an arbitrary string at that which acts as a “key”. I’m passing an ID (a long in this case) to the next activity as the “value”. (The coalesce operator is because my entity has nullable ints, but the -1 will never be used in this case).

Over in the PortfolioActivity, I simply use Intent.GetLongExtra(Extra_PortfolioID, -1); to get the ID number out back out of the intent object. I’m again using that arbitrary Extra_PortfolioID string as the key. The “-1″ is the default value, since technically the data is being serialized, but because of the way I’ve written the app, that value won’t ever be used. Then I can query my database with that ID or do whatever I need to do.

Monodroid – starting a new activity

I’m writing a Monodroid app that has a main “dashboard” screen and several other “child” screens. Here is how I wire up a button to start up one of the “children” screens:

Note that the static “ClassName” property is just a string, and my lame attempt at not repeating magic strings. The value is “monoStockPortfolio.AddPortfolioActivity”, which can be found in your AndroidManifest.xml.

The “intent” object can be used to pass information to the child screen, which I’ll show in a later post. By using “StartActivityForResult”, the user can click the “back” button found on all Android devices to leave the child screen (with the correct transition). Alternatively, here is how the user can get back without using the back button (i.e. they complete some task on the child screen):

Here I’m saving a new portfolio with a repository, but the key part is the last 3 lines. I’m creating another Intent object, but I’m using it to set a “result” (recall that I used StartActivityForResult to get here). And then I’m calling “Finish” to end the activity.

You can check out the full source code of this project as I go along at GitHub.

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress