Ground-Up Android, Part 5: Tweeting and Debugging

October 7th, 2009 by Yoni Samlan

This is part 5 of a 5-part series on introductory Android development. If you’re just arriving, you should head on over to Part 1.

In Part 4, we dug into accessing our Views from our Activity’s code, and registered an OnClickListener to handle the user’s interactions with our button. In the final part (a big one!) we’ll cover using J2SE libraries, debugging, and Android permissions.

So far we’ve gotten a lot done without too much “boilerplate” coding, and that’s great. But what we don’t have (yet) is an application that leaves its mark on the world. After all, what’s a Twitter application if people can’t benefit from your 140 characters of deep, meaningful insight into the state of the world (or what you ate for breakfast)?

Read the rest of this entry »

Ground-Up Android, Part 4: Writing the Code

October 7th, 2009 by Yoni Samlan

This is part 4 of a 5-part series on introductory Android development. If you’re just arriving, you should head on over to Part 1.

In Part 3, we defined our layout and prettied up our app’s main screen. Now let’s get to the business of real coding – the stuff that makes the app tick behind the scenes.

Read the rest of this entry »

Ground-Up Android, Part 3: Describing Your Layout

October 7th, 2009 by Yoni Samlan

This is part 3 of a 5-part series on introductory Android development. If you’re just arriving, you should head on over to Part 1.

In Part 2, we started an Android project, poked around it a little, and launched an emulator. Now we’ll move on to making the app look like what we want.

You’ll notice I titled this part “Describing Your Layout,” not “Coding Your Layout” or “Programming Your Views.” This is because Android gives you the tools to define most of the characteristics of your Activity’s visuals in descriptive, not procedural terms. This helps speed up development, thanks to the nice GUI-based tools for layout, and helps you keep your programming logic out of the places you define your application’s outward appearances (and vice versa). It’s important to know that you could create your entire app in Java, writing the descriptive code for your layout procedurally in your Activity instead, but it’s a much better idea to keep things separate wherever possible.

The resources

We’re going to build a basic Twitter client, so let’s make it look like one. Let’s switch back into Eclipse and poke around at what we have so far. You’ll recall that besides our Activity’s Java file, we have layout and strings files in the res/layout and res/values folders. Let’s go check them out.

Here’s the basic layout the wizard created for us in res/layout/main.xml:

the main layout xml

The main layout xml

Read the rest of this entry »

Ground-Up Android, Part 2: Our First Project

October 7th, 2009 by Yoni Samlan

This is part 2 of a 5-part series on introductory Android development. If you’re just arriving, you should head on over to Part 1.

In the first part of the tutorial, we got Eclipse, the Android SDK, and the ADT set up. In this part, we’ll get into our environment, create our first project and poke around in it, and test out the Android emulator.

Fire It Up

Go ahead and fire up Eclipse, and if it asks, choose a workspace (the default’s probably fine for now). Click on the “new android project” button or go to File -> New -> Android Project.

Click the New Android Project button.

Click the New Android Project button.


Read the rest of this entry »

Ground-Up Android: Getting Started with App Development

October 7th, 2009 by Yoni Samlan

This is part 1 of a 5-part series on introductory Android development.

Thinking about testing the waters with Android development? Jump right in. We’ll build a neat little application that interacts with a web service.

Yup.

Yup.

Which one? Twitter, of course.

This is a web form of a talk I gave with Henry Cipolla, CTO of Localytics, at BarCamp Boston 4 and in a longer form at FITC Mobile 2009, updated to cover the 1.6 (”Donut”) release of the Android SDK. The slideshow portion of that talk covers the basic concepts of the platform and slides are available online. I recommend checking it out.

Read the rest of this entry »

Code and Slides from FITC Mobile 2009

September 14th, 2009 by Yoni Samlan

For those of you checking out our presentations at FITC Mobile, here’s the source code for the first session on introductory Android development, and the more complete source code for the second session on Android homescreen appwidgets.

The slides for our intro presentation are hosted on Prezi. Henry will be doing a narrated screencast of his part at some point in the next few weeks, and I’ll be doing a more complete writeup of the code portion with notes in a later post here on Active Frequency’s blog.

You’ll notice I linked in specific files from JTwitter rather than just including the .jar; there’s a lot of unnecessary code in the .jar and the J2SE source is a little lighter and cleaner, and hopefully makes it especially clear what the Twitter client is actually doing.

The demos use the JTwitter library (LGPL), and the icon is from a great Creative Commons set called Tweeties by Chris Wallace.

Active Frequency at FITC Mobile 2009

September 12th, 2009 by Yoni Samlan

fitc-mobile-logo

FITC Mobile 2009 kicks off tomorrow morning in Toronto. I’ll be leading two developer-geared sessions: Diving Into Android Development (with Henry Cipolla of Localytics) and Android Homescreen AppWidgets.

I’ll also be posting slides, notes, and code from the sessions to this blog during the conference, and occasionally Tweeting from our new Twitter account.

Come by and say hi if you’re going to be there!

Things That Are Awesome

September 9th, 2009 by Kevin Grinberg

Awesome: DC App Store, a repository of apps and mashups based on DC data feeds.

My fave: Park It DC, possible by the District providing useful data feeds.

15 New Kick-Ass Cupcake Features

April 20th, 2009 by Yoni Samlan

splashscreen-logoAndroid’s much ballyhooed 1.5 release (aka Cupcake) seems to be imminent. Last week, Google released a preview version of the SDK, and I’ve dug through it a bit and kicked the tires. In honor of the impending 1.5 release, here are 15 neat features I really dig.

Read the rest of this entry »

Changing Android DRM Breaks Apps

April 7th, 2009 by Yoni Samlan

**UPDATE (4/20/2009) – a Google employee has commented on the open bug report and says this will be fixed in a future software release. Whether this makes it into the impending Cupcake update is anyone’s guess, though.**

Today we released the 1.1 update to RockOut Acoustic Pro. This update adds some neat new features like “Fretting Mode,” which lets you hold the screen to “fret” chords and strum using the trackball. We thoroughly tested the application for both new installs and updates from the old version, on both the Android emulator and an actual G1. Everything looked good.

But when we actually put the update on the Market, some users complained the app was automatically force closing (read: crashing) when they installed the update.

I couldn’t reproduce it, but then a user sent me his log files (thanks to the wonderful Log Collector app). Here’s some relevant parts, and then the explanation:

E/PackageManager( 51): Package com.activefrequency.android.rockoutacousticpro has mismatched uid: 10046 on disk, 10047 in settings; read messages:
...
E/Database( 228): sqlite3_open_v2("/data/data/com.activefrequency.android.rockoutacousticpro/databases/song_list.db", &handle, 6, NULL) failed
...

Here’s why this happened: When we first released RockOut Acoustic Pro we had copy protection turned on. I turned it off a day or two later because an odd Market bug that Google won’t really acknowledge causes copy protected apps not to show at all on the market on many phones (normal G1s, not just ADPs).

This only happened, as far as I can tell, to users who previously had the copy protected version of my app installed.

The copy protection mechanism changes the uid of the application, so that non-copy-protected versions of the same app signed by the same key are no longer recognized as the same application, and are denied access to the database and other resources for the application.

This is never documented anywhere in any official Market or Android documentation, as far as I can see.

Plus, we had no way to figure this out on our own because developers can never install their own paid apps off the market, therefore can never test the copy-protected versions of their apps!

Now that I actually know the root cause of the problem, it’s easy enough to google and I can see I’m not the first dev burned by it.

There’s a ticket to fix this but no progress that I can see. This means Google is aware of the problem, yet doesn’t tell you about it when they know you’re about to break updates for your app by checking or unchecking the copy protection box. This is a 100% predictable result, and should be simple to warn developers about before they hurt their reputation or suddenly get dozens of negative reviews.

The absolute bare minimum Google can do is DOCUMENT this. I can’t see it taking more than 10 minutes to add a warning box when you add or remove copy protection from an app already live on the market, and it would have saved me a good hour of frantic hunting for a bug in my code that wasn’t there.

Is just disclosing this to developers too much to ask?