Android has finally been released by Google and has been making headlines around the dev community. I believe it will be a strong competitor against the Symbian OS and its applications. Currently, Android supports only the Java language, but maybe later on other languages will also be supported. To get your SDK, go here.

Every language always has sample codes provided to help the developer get started and it’s no different with Android. I’m placing a post on how to get started to help developers because I had a hard time actually running a simple hello world application. My desktop PC is running under windows os, once you get the SDK extract it to anywhere you like. To compile Android applications, you can either do it using Eclipse IDE because it has a plugin that does the packaging and compilation of the apps, or use a builder like Ant. I use Ant because you can’t learn the intricacies of the code if you depend too much with IDEs.

To create a new project, use this command.

activityCreator [--out ]

The necessary files will be created automatically for you. Go to the File of WhateverName and change the contents of the onCreate() method with this.

TextView tv = new TextView(this);
tv.setText("Hello, Android");

I set the tools location in my environment variables so that I can run it anywhere within the ms-dos console.

You may possibly encounter an error with paths during compilation. Within the Ant script, it actually has an entry there that uses the dx.bat to convert class files to Dalvik executable format (.dex). Just go to the tools folder again and modify the dx.bat file and change the part where dx.jar is indicated so that this file can be seen by the compiler in its classpath.

Once compiled, run emulator by typing emulator and in another ms-dos console, run adb devices. That command starts the adb server if it is not running. Take note that the emulator loads very long on startup. It took me days to figure out that I never did anything wrong but that the emulator just took a long time to load itself up. When the emulator screen pops up, you’ll see the word ANDROID and then after awhile a short red line moving left and right. I thought this was sort of an idle mode for the emulator. Turned out to be like a loading indicator.

You do not need to wait for the emulator to finish loading before installing your application in order to see it. You can use this command to install the Android package.

adb install [pathto]\[package.file]

When your emulator finishes loading itself, you will see your application icon with the title of the app. Click on that and you will see the Hello, Android text. It’s fairly easy when you know the where’s and what of compiling Android applications. I, however had a different situation that it took me a few days to fully understand how the tools work. Android’s documentation focuses mostly using the Eclipse IDE so those who do not like using it, can find this post useful.

I forgot to post this one in my blog when I found out lyrics can now be seen in iTouch’s firmware of 1.1.3. I’ve been wondering myself why Apple took a very long time to have this feature enabled. Actually even with the firmware 1.1.3 they never announced it. With this, we can finally sing a long while we listen to our favorite music.

Adding lyrics is an old feature of iTunes though. Just copy and paste it in the Lyrics tab of the music in iTunes when you select its properties. Now, we can finally make use of the lyrics. Keep in mind though, that this feature is not found in nano video or below. only with iPhone and iTouch. Searching for lyrics and pasting them one by one is a hassle though, but there’s a neat widget in Mac that actually fetches the lyrics for you when you play the music in your iTunes. The widget is called TunesTEXT. Pretty nifty, saves you all the trouble of finding the lyrics.

If you want all your mp3s to have lyrics, just leave your iTunes running. Once the next song plays, TunesTEXT automatically searches for the song and appends it into the mp3 file. Now, I can really say owning an iTouch is very much worth it. This was the number 1 feature that I wanted ever since iPod was created and it’s finally here.

Java and Javascript have different ways to replace strings like the feature “find and replace” that you see in text editors.

Java’s replace method is not ideal for noobs but only for people who know about regex. I am not that quite familiar with regex and if you wish to use that replace method under the String class in Java, you’d have to familiarize yourself with it in order to use it. The String class though, has lots of other useful methods that can be used to simulate how a search and replace function works. Here is a workaround method for people who only want a simple search and replace with the search and target both String. No regex knowledge needed.

The replace function contains two options. ‘i’ means the search would be case insensitive and ‘g’ means global, meaning it will search all instances of the search string within the str variable. If you do not include ‘g’ as its option, then only the first instance of the search string will be replaced.

Java and Javascript should have provided simple replace methods that greatly help newbies to these languages. The replaceString() method in Java is a good workaround for easy to use search and replace purposes in java.

Related Posts Plugin for WordPress, Blogger...