Finishing off my port now! Once it’s done I’ll do the whole “Android vs. iPhone” breakdown, but for now here’s just a few more gotchyas you may hit:
- If you want to start an activity, remember that you have to add it to your app’s XML manifest file. Don’t worry, it only takes you a few iterations on “run, get exception, wonder why, remember” until you mind remembers to do this. It’s be great if some Java guy could integrate this into Eclipse so that when you created a new class you could have it automatically insert it.
- URIs are not strings. To get from a URI to a string, use toString(). To go the other way, use parse().
- Want to pop up a message box? In Android the class you need is AlertDialog. Here’s some sweet sample code:
new AlertDialog.Builder(this).setTitle("Title").
setMessage("Yo").setPositiveButton("OK",
new DialogInterface.OnClickListener()
{ /* whatever */ } ).show();
I found that code on the anddev forums. Message boxes were tricky to figure out because there used to be a different way to show them that was removed as the SDK matured. Also check out how the click listener method is specified via anonymous delegate.
Posted in android | No Comments »
I’ve started porting my iPhone app to Android/G1 in anticipation of Google’s market for paid apps launching later this quarter (I want to be in on the ground floor!) Java is very C# (actually, that’s incorrect, since most of the awesome stuff in C# was blatantly ripped off from Java, which had it years if not decades before but ANYWAY) – Here’s how I’ve started on Android and how others might want to start:
- go to code.google.com/android and go through all 4 steps of the getting started. Pay your $25 and if you can stomach it, plop down another $400 for the Android Dev Phone, which is an unlocked G1 with a cool skin.
- Download and integrate into Eclipse a package called CDT – C++ Development Tools. It comes with a DevStudio keyboard configuration that’ll save you some sanity; Eclipse is huge, and the keyboard shortcuts aren’t intuitive. For example, Ctrl+Tab and Ctrl+Shift+Tab don’t cycle between windows (which is what finally led me to find out about CDT).
- download DroidDraw, which is the best GUI drawing tool (like Interface Builder or the Design View of C#) that I’ve found. That isn’t saying a lot though, this tool is still young and cantankerous, but at least it gives you a graphical view of the XML files that Android uses for UIs.
- This site (www.androidph.com) has lots of code snippets to look at. Also check out AndDev, which has some cool tutorials and a good community going.
- Tell me about other things you find!
Posted in android | No Comments »