Android Programming for n00b’s

I’m teaching myself programming on the android, and I’m a total n00b. I have NO experience in java, and no experience in android either, so I’m really starting from the ground floor. If this sounds like you, check back here often, as I’ll share my experiences, successes, and failures here, so that hopefully you can learn from my mistakes. If these postings make your programming life a little easier, please post a response and let me know!

I don’t know about you, but when I’m working on something “for fun” I generally break all the rules for the design and coding of the project. You can see many examples of this by reading my archives here, or by visiting my other blog about robots. You’ll find lots of fun stuff there, and since it’s all for fun, I generally don’t follow specific “best practices”. In fact, I generally follow the “jump in with both feet and see how you land” practices. This sometimes results in some strange consequences, and projects that wind up looking nothing at all like their original concepts.

Back to android…

I’m developing on a MAC, using Eclipse, and my android devices consist of a Driod and the emulator. I won’t go into detail on how to install and setup eclipse and the android SDK, there are many tutorials on the web; simply google “Developing for Android” to get you started. I’ll start by assuming that you have eclipse, the android SDK installed, and everything is working. With that out of the way, first things first:

Shut down eclipse. Leave it alone for a while. Go download this: DroidDraw. This handy-dandy little tool will let you draw screens much like using visual studio. For me it is an INVALUABLE tool. I can mock up screens, push them over to the device to see how they look, and most importantly, use it to create the layout files (Android uses XML files to define screens) and see how the code looks. I learn by example, and this tool had me designing screens and reviewing code within 2 minutes of downloading. Go get it. You’ll be glad you did.

Using Droid Draw, together with eclipse, I had a basic application laid out in just about an hour, and using it to genrate the xml files, I was able to cut and paste these into the eclipse environment and get my first application running in about 30 minutes. Granted – it wasn’t fancy (just barely beyond “hello world”), but it was mine.

Don’t get too excited. There is still a very steep learning curve ahead, and I guarantee you aren’t going to be making a marketable app in the next day or so, but trust me – if you are a n00b like me, you’ll have fun, and you’ll learn a few things too. Believe me – there is LOTS to learn. It took my 5 days to learn how to build a simple 5 button menu.

For now let me give you a couple of simple pointers….

Your android application is stored in several files. Eclipse lays most of them out for you…. You’ll need a main.xml file – this will hold your main startup screen layout. You’ll need a java file, named after your application. This is your main program file, all code launches from here. You’ll get some System Generated files (main one to think about is R.java – don’t edit this file). You’ll have an android .jar file which holds the android functions and things, and you may have additional xml files that contain string definitions, menu definitions, color definitions and things like that. At first I was completely overwhelmed by the sheer volume of files; but I quickly got used to it. If you are creating a string for a label on a button, for example, you’ll store it in strings.xml. Want a background color for your text? It’s stored in colors.xml.Each screen is names and stored in an xml file. It’s a lot of files, but in an organizational way – it’s handy.

One very important file is your AndroidManifest.xml file. This file is kind of like the main menu of your application… (it’s a poor analogy). You tell the system about activities (tasks or screens), setup information, distribution information and other package information using this file. It’s easy to forget. I’ve forgotten several times. I’ve forgotten so many times that I generally look in this file first to see what I’ve screwed up.

So use Droid Draw, and create a few screens. Get your creative juices flowing. After you get comfortable, putting buttons, checkboxes, changing colors, etc, settle on a simple application, and get started building it. Check back with me. I’ll talk about the things that tripp (or tripped) me up. Hopefully, I can save you some grief, because believe me, there is plenty to be had…. Did I tell you it took me 5 days to get 5 menu buttons to work? Seriously. Lots of help out there to tell you how to use ONE button, but use more than one? Forget it. Look here for my next post!

See ya!

Linux, Robots, and Games, Oh My!

I know, I know. I’ve been slacking quite a bit on this blog, and it’s time I made up for it. I’d like to tell you that it’s been a busy summer, what with weddings, babies being born, homes being bought, homes burning down, and an important election; but you really don’t care about all that. I know. I just need to “Man-Up” (to parrot our politicians) and get back to work. So here you go.

LINUX Musings:

OK – I *like* fedora. I always though it was pretty easy to install and configure. Just get it installed, run “yum update” when finished. Sure – there were the occasional glitches, such as no drivers for your RAID, mis-configured NICS, SELINUX failures, and crashes on the updater…. And of course you have to configure your own server-side applications like Postfix and NAMED by using an editor and understanding geeky terms like “address_verify_sender_dependent_relayhost_transport_maps” and “default_desitination_concurrency_cohort_limit”. But I  like that stuff. It separates me from the “rest of the pack” so to speak. Keeps me employed. And every time I talk about setting a value for “lmpt_cname_overrides_servername” during morning break, everyone starts making excuses and soon I have the break room to myself!

My Geeky son told me some time ago to try Ubuntu. He said is does a much better job of installing, and determining dependencies; and the configuration tools were much better. So I tried it.

On a Windows box I simply downloaded wubi-installer from the ubuntu download site. It was way too easy. They have a BIG orange button on the page, all “right there in your face” that says pretty much “Step One and Only. Start Download”, and your off and running.

After it downloaded to my desktop it took off and ran. It created and installed dual-boot partitions, asked very simple questions and self-configured; after which, it ran. In fact – it auto-updated (with no trouble) and continued to run. Just fine. I didn’t have to open a single text file. I never once had to google an issue, or ask about an uber-geeky setting buried deep in the system-config-firewall application.

I’m so disappointed. What am I gonna talk about in the break room now?

I’ve added some more Arduino code over at my robot blog, go take a look!

AND – I’ve started working on an app for the Android. Learning how that all works. Easier than the iphone, but that’s probably just me.

See ya!

Update: Control Serial Devices from Web Page

OK, so here’s a little followup to one of my previous posts. I’ve got a robot, that I want to be able to control from a web page. This means I have a PIC controller (an Arduino) controlling some motors, sensors, etc, that I need to be able to access from a web page. I wrote a little app using .NET that listens on the TCP wire for a command, and then converts it to a serial command which it sends to the PIC. Quite handy, as with this app, you could write your own controller for serial devices such as alarms, sensors, power supplies, etc. and take complete control of your rack from anywhere in the world.

I’ve updated the code for the web page, together with the serial controller to allow you to specify the serial port to target, and the command to send, as well as provide feedback to the page, so now it’s async and gives you much more control. You can review the code here if you want to see it, or you can connect and control the camera if you want to see it in action. Registration is required, but it’s so I can control access, I’m not using your email for any other purpose.

Installed postfix, but no qshape?

Here’s a simple one…

I installed a new FC12, and postfix, using “yum install postfix”. Afterward, after configuring main.cf, postfix ran fine through our simple testing, so I put it in service on a limited basis. However, once we started using it, qshape failed, with an error indicating it was not found.

It took me a couple of hours of my poor google skills to find the answer, so hopefully, if you find yourself in the same pickle, you can use this and it will help you.

First, separately install all the perl packages with this command:

“yum groupinstall perl development”  once you have that all done, (and here’s the magic) run:

“yum install postfix-perl-scripts”.

I know, qshape is *supposed* to be installed with postfix.  Only it wasn’t. and it took me all morning to figure out how to get it in there….

…..It worked for me.

Is IPhone/XCODE SDK Buggy? + FIX for Dell Poweredge 2650 RAID

Is the IPHONE Development system buggy? Apparently so.

I’ve recently begun “trying” to learn how to develop aps for the IPhone, and am hving a helluva time. I don’t know about you, but usually I learn by gathering examples from (my friend) google, and then as I run into questions, go seek out the answers. It may not be as efficient (or as expensive) as my son’s recent college education, but it has always worked for me in the past. In fact, I can usually get up to speed faster than my business needs dictate, especially for simple little one-off tasks.

Not in this case.

I’ve purchased 2 books (120 bucks), downloaded a TON of examples, and I’m really, really struggling. It seems that I’m having a lot of trouble following written examples, as the IDE doesn’t behave as expected. Disappearing code, “File’s Owner” troubles, errant behavior, it goes on and on.

I grant that I’m also struggling with the unusual syntax (unusual to me, anyway), but does anyone else have this trouble? Sometimes, after struggling with some particular issue for a couple of hours, I’ll reboot in frustration, and *poof* the code starts working (particularly when trying to assign the “File’s Owner” attributes), meaning I’ve just wasted a couple of hours of work, and ran down dozens of bunny trails….

If you have a suggestion of value, I’d love to hear it.  I’m on OS X, Snow Leopard, and XCODE 3.2.1. Shoot me an email or reply post.

Now for my actual post target.

I’ve *also* been struggling trying to get FC installed on a DELL Poweredge 2650 with onboard RAID. The symptom is a complete and troublefree installation, then “No Boot”.  FC10 and FC11. The good news is that it works OK in FC12, but then FC12 is pretty new, so I’m certainly not getting ready to put in production. If you are using a DELL Poweredge 2650 (or any other Adaptec RAID controller with 3 or more drives in it, per BUGZILLA), you’re likely to have trouble with FC10 and FC11. Stay with 9, or move to 12, if you dare…..

Bugzilla reports there is an issue with a missing aacraid driver file, which is causing a timeout issue when querying the drives.

I’m going to try to learn how to patch in this driver without a re-compile (if possible), but for now, it’s fc9 for this system.

Good Luck!