Home > Android, Gaming, Programming > Learning Android

Learning Android

Ok, time to attempt to revive this blog again. I recently decided to attempt to teach myself how to program for the Android mobile OS. This has proven to be difficult, fun, and interesting. The major hurdle that I had to get over was the fact that I am primarily a C/C++ programmer. While I’ve used many languages, the projects of which I’m most proud were coded in C and C++. I’ve tried Java many times and every time I hated it, despite it technically being my first real programming language (disclaimer: after a year of TrueBasic). I don’t fault the language however, it’s just my own personal taste. However, I really wanted to try coding for Android and thus began this adventure.

I decided that I would chronicle this journey in the hopes that someone else attempting to teach themselves how to program for Android could use this as kind of a tutorial. So of course my first stop was to download the Android SDK from Google’s developer site. At this point I had to choose my IDE. I’ve not done anything in Java for years so I did a little searching. While Google provides a plugin for Eclipse, I chose to go with Netbeans due to my previous experience with it, along with seeing posts from everyone describing how Eclipse is great except for having to restart it every few hours due to it leaking memory like a sieve.

Once I’d set up my environment (like so) I was ready to start playing around. Then I found the Android Plugin for NetBeans which made me very happy. You can get it here. I got the gist of things by doing the first couple tutorials from the developer site, but decided to sink my teeth into something a bit more fun, this is where I’ll delve into code =P.

Back in college I created a Connect 4 game for an AI course, this was written in C++. I decided my goal would be to recreate this as an Android App. So I started by picking apart the sample code for a TicTacToe game. It is very useful having my own Droid phone handy and using it as a dev device. If you go into the settings for the device you can turn USB Debugging on, and easily install the package on my phone, test it out, and remove it. In order to do this, you first have to set up your computer to recognize the device. For those of you that use Ubuntu like me, or any system that uses udev, just create the file /etc/udev/rules.d/51-android.rules and put SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666" in it where "0bb4" matches the device id on the following table:

Vendor Device ID
Acer 0502
Dell 413c
Foxconn 0489
Garmin-Asus 091E
HTC 0bb4
Huawei 12d1
Kyocera 0482
LG 1004
Motorola 22b8
Nvidia 0955
Pantech 10A9
Samsung 04e8
Sharp 04dd
Sony Ericsson 0fce
ZTE 19D2

Then simply run the command chmod a+r /etc/udev/rules.d/51-android.rules to make it executable. If you’ve set up your development environment as described in the above links, you can use the “adb” tool that was provided in the SDK to interact with your device. If you get an error about permissions, then you must start the daemon as root to have access to the device.

In my next post I’ll go into what I learned from the TicTacToeLib source code sample and walk through the steps I took creating my connect 4 game.

Categories: Android, Gaming, Programming
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *