Mittwoch, 30. Dezember 2009

First Steps with Android

In the last few days I started out with some android development. Here are some things learned so far developing my first app:

  • The Android Tutorials are a great starting point, though i only followed through with the HelloWorld Tutorial. In retrospect I should have looked at the Notepad Tutorial a little closer because it explains important concepts (namely activities/intents).

  • http://www.anddev.org/ is a useful source for tutorials and code snippets

  • It's still java but a completely different API, so you often have to look for classes and methods via code completion oder in examples to get things done.

  • Downloading: Can be done with the included HTTP Client library. Unfortuantely Android still uses an old version of the HTTP Client though, which made it hard to find documentation (e.g. how to set authentication credentials). Additionally you shoudn't forget to declare the INTERNET-permissions in your application manifest.

  • Storing and retrieving Files looks fairly easy (getDir(), getCacheDir()-Methods are there) at first sight but you have to unerstand the Android filesystem security model if you don't want to spend hours with debugging. The before mentoined methods use internal storage where each application stores it's data independently. Public read/write (e.g. file exchange with other applications) is only possible when you store your content with the specific method openFileOutput(). The external SD card on the other hand can be openly accessed with the regular Java File API.

  • XML Parsing: I started out with the sax parser but since my XML file was pretty complex I ditched it and downloaded dom4j which has a really easy to use API. Unfortunately it adds at least 200KB of final app size. I now realized I could have gone with the regular DOM parser which has a decent API. I'll have to reevaluate this later - maybe the end user responsiveness does require the faster streaming parser approach (sax).

  • UI design: Declarative XML based looks powerful and well thought out but I mostly stuck to tutorial layout for now. This is an area I still have to get into.


Ok, that's it for now. Android is turning out to be a great plattform - exciting times.

Donnerstag, 6. August 2009

Adding Googles GData Java API to your maven repository

The google gdata apis do not come with maven POM-files. Someone went through the trouble to "mavenize" the source but it is limited to linux as build plattform and currently out of date (compile errors). So I installed the JARs from the binary distribution of the APIs into my local repository - which are of course missing the dependencies between the individual JAR files. Here are two batch files which I used to install the JARs quite painlessly:

install.bat:

@SET mvn=d:\java\maven\bin\mvn
@%mvn% install:install-file -DgroupId=com.google.gdata
-DartifactId=%1 -Dversion=%2 -Dfile=%3 -Dpackaging=jar
-DgeneratePom=true


installall.bat:

call install.bat gdata-analytics 2.0 gdata-analytics-2.0.jar
call install.bat gdata-appsforyourdomain 1.0 gdata-appsforyourdomain-1.0.jar
call install.bat gdata-base 1.0 gdata-base-1.0.jar
call install.bat gdata-blogger 2.0 gdata-blogger-2.0.jar
call install.bat gdata-books 1.0 gdata-books-1.0.jar
call install.bat gdata-calendar 1.0 gdata-calendar-2.0.jar
call install.bat gdata-client 1.0 gdata-client-1.0.jar
call install.bat gdata-codesearch 2.0 gdata-codesearch-2.0.jar
call install.bat gdata-contacts 3.0 gdata-contacts-3.0.jar
call install.bat gdata-core 1.0 gdata-core-1.0.jar
call install.bat gdata-docs 2.0 gdata-docs-2.0.jar
call install.bat gdata-finance 2.0 gdata-finance-2.0.jar
call install.bat gdata-health 2.0 gdata-health-2.0.jar
call install.bat gdata-maps 2.0 gdata-maps-2.0.jar
call install.bat gdata-media 1.0 gdata-media-1.0.jar
call install.bat gdata-photos 2.0 gdata-photos-2.0.jar
call install.bat gdata-spreadsheet 3.0 gdata-spreadsheet-3.0.jar
call install.bat gdata-webmastertools 2.0 gdata-webmastertools-2.0.jar
call install.bat gdata-youtube 2.0 gdata-youtube-2.0.jar


You surely could get fancy and automate the splitting between artifact-name and version number, but hey, I needed those JARs installed quickly and that's what it does.

Sonntag, 26. Juli 2009

Splitting mp3/cue files into multiple mp3 files

Usually you encode single MP3 files for each track on a CD. But there are cases when it's sensible to encode the whole CD as one MP3 file. This is usually done, when you have a continuos live album where you want to avoid gaps between the tracks und preserve the original timecodes of the CD. In these cases you create a single MP3 file and a CUE file which contains the timecodes and track names for the single tracks in the MP3.

When you later like to split thes MP3/CUE files into individial MP3 files you need a specialized tool. Lately I used Medieval CUE Splitter to achieve this. It is a small freeware application which splits the MP3 and even fill the ID3-Tags from the information in the CUE files.

Donnerstag, 23. Juli 2009

"Continue later" for filling out Google Docs Forms

Google Docs/Spreadsheets forms can be used easily as a simple survey tool. You just have to send a link to the participants who have to fill out and submit the form. The only problem: The forms have to be filled out in one go, you can not come back later and continue editing the form. Of cause this is particularly bad when you a have a really long questionnaire.

On way to provide the "continue later" functionality is to use a tool that saves your web browser's form state. Lazarus: Form Recovery is one of those tools for Firefox that constantly saves the state of your web forms and allows you to load previous content when you return to a website. This works very well with Google Docs Forms. You can interrupt filling out the form at any time, return later and restore the information you previously entered with a few clicks.

Samstag, 18. Juli 2009

IndexedList: A hybrid of a Java List and a Map

If been working on legacy data import code in the last months with a lot of code searching for exisiting objects in lists. I realized I needed a different collection to speed up searching for identifiers and couldn't find any standard collection that matches my needs. I basically need an index like Maps.uniqueIndex() from the Google Collections Library provides but it should be updating dynamically and not only be generated once.

Freitag, 17. Juli 2009

techbits' back

I had to bring techbits back from the dead - I have lots more to say. I know that I rarely find time to write long and carefully crafted articles but I'd rather contine posting short notes twitter style than not posting at all.

Wordpress is updated, a new fresh theme is installed, now I'm going to update some about data and clean up the sidebar. Expect upcoming posts about Java, Alfresco, GWT and some general development topics that cross my mind.