Thursday, September 2, 2010

Android Development Tutorial/Overview - with sample code.

Android Development/Programming:
The basic concept of android is JFX(or JSP) like development of UI in java. You should know that android testing using emulator is very slow (unless you do it on an actual device eg droid incredible)- and unlike iphone you can freely deploy your apps on your phone. Android (like java permission file or vista/widows 7 model) like to warn before installing application - and applications have to indicate what kind of permission it needs.


Prerequisites:
Before starting Android development - you should know java first - by reading books like Core java (other programming back ground is useful) etc


Getting Started:
You should get started using :

http://www.vogella.de/articles/Android/article.html (or androids website).

Other links:

With android - you have to develop java program like in 90s(but at least its still java) :
http://developer.android.com/guide/practices/design/performance.html

You can access unix shell (eg adb shell) and analyze memory from this tutorial:
http://kohlerm.blogspot.com/2009/04/analyzing-memory-usage-off-your-android.html


 

Open GL ES

Android uses Open GL ES(subset of Open Gl for mobile ) for game development- just like Iphone.
 Its however tough to find good books or a good tutorial on Open Gl Es for android.

Android Game video tutorial:
http://www.edu4java.com/androidgame.html

Android 3D game tutorial

http://www.droidnova.com/android-3d-game-tutorial-part-i,312.html

Making games on Android
http://www.brighthub.com/hubfolio/matthew-casperson/blog/archive/2010/01/04/making-games-on-android.aspx

Getting started Link -in games - http://www.brighthub.com/hubfolio/matthew-casperson/blog/archive/2010/01/04/making-games-on-android.aspx

OpenGlEs for Iphone(similar to OpenGl Es on Android)
http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html

Opengl(not openGles) redbook
http://fly.cc.fer.hr/~unreal/theredbook/

 

 
Android Books :

a) General Ones: 
This a tough one(as they are moderate quality or will easily get outdated).
However top books seems to be :
Professional Android 2 application development (This one covers most topics-  but does not explain in detail)

Pro Android 2 ( This one is similar to above book.. But I dont like reading on the cheap - yellow paperback pages provided by apress . This book was hard for me to get online - but i could preview it at barnes and nobles store - and it seemed verbose to me. )

The above two books covers the most topics - and may be your best bet now(yet- june 2010).. However there style is not good(verbose, making book huge with code/examples without clearly explaining them)
(The Unlocking Android seemed promising to me - but was outdated.  The Hello, Android may be promising. I however liked the tutorial style(not content) of the heavily criticized book - Android Application Development: Programming with the Google SDK )
 
I have however chosen to download pdf books from http://www.commonsware.com/ which provided good content for the price - but its not a replacement for having physical book in your hand.(This site however did not post to https by default- and had no facility to change password)

b) Game Books:
There are insufficient material on developing games. But here you go:
Pro Android Games  (its useful - only if you already know open gl and c++)
Beginning Android Games (not yet released)

You may need to buy books to brush your maths (but first try some games and see if you get around by googling)
 3D Math Primer for Graphics and Game Development (Wordware Game Math Library)

Mathematics for 3D Game Programming & Computer Graphics (Game Development Series (Charles River Media).)



Running google Samples:
Once you have got your eclipse setup . The next step is to run google samples(that you downloaded with sdk).
If you are developing games - then googles snake example is a good one to start.

If you have a sample android project (new android project) in eclipse  then - Copy googles sample
code for Snake into your project - and then remove main.xml from res/layout.
(or preferably use New Android Project ->Create project from existing sources)

You should now be able to run it on your device(like incredible) or emulator..
For me the emulator took to much time and I gave up. On incredible it ran OK on second
attempt(after doing force crash on first).
While running it - it displayed a confusing message that I need to press on some "up button".
to start playing. I quickly realized that they meant - that i need to move the track ball up.(I hardly use the
weird track ball in droid incredible)

NOTE: If your PC (or maybe phone) is sleeping then this device may go offline.
Hence you may get below error:

[2010-06-03 13:06:23 - Demo ] java.io.IOException: device (HT0DEVICE) request rejected: device offline
To fix this just kill adb.exe (From task manager)  or try restarting eclipse.

MY FIRST SAMPLE CODE on Android(droid incredible):
I looked at googles sample code for Text To speech. It was too much details for a sample . Hence I used it to write my own sample. The full code of my Text to speech sample code is here:

http://android-java.blogspot.com/2010/05/tutorial-to-develop-text-to-speech-app.html



Deploying on HTC droid incredible :
The current google sdk(2.1 version 7) does not have incredible settings in its
USB configuration file. Hence when you connect your computer to charge it.
It may say that "ADB" could not be installed. Without it - you will not
be able to see - droid incredible - in target devices in eclipse(or adb devices will
not show anything).
I followed instructions on : http://www.flexjunk.com/2010/05/01/installing-htc-incredible-android-sd-drivers/
It did work on one of my xp machine(but strangely I could not make
it work on another XP machine.. maybe due to jdk or driver corruption).. Be careful
- in trying USB debugger to fix this(as my antivirus says that most of them have virus)


Running on droid incredible device :
After the ADB was installed- I just created default android project .
I then ran it - and it automatically chose my htc as target(as i did not set up any other emulator devices) . It also automatically installed in my device(with android market icon). I was pleasantly surprised that it ran immediately!(ie did not take forever to load/run  - unlike when you run with emulator. It may make sense to directly
test on device.
Debugging Issue: However - i made some mistake when I tried to run TextToSpeech sample provided by google sdk(after I edited it).. It did not give any good error message . All it said on the device was that - I need to press button to forcibly close the application.  Luckily - I knew the changes I made and i removed it.(it was perfectly compile application - but i had added some color stuff). Hence I would recommend that you do development in  small steps - else you wont know - why your stuff is failing.


Other notes:
  • There is no api to send automated email(you can just open email window).
However strangely there is api to send automated SMS(which can cost money
and abused by virus) For sending email you may have to use (huge size) - ported version of javamail(as javamail is dependent on awt).

  • There is facility in the api to "place phone call" . But I could not find anyway to hook - my text to speech sample into it.(ie can not leave automated telephony message)

        This will also allow you to delegate UI updates to be controlled on server.(as most users will not update apps). This is a good approach for many apps. The security etc are being handled by traditional mechanism.
  • Once you install sdk - you can use ddms.bat from tools directory - > Choose a device -> and do device capture to do screen shots of stuff in your phone.
  • If you want to develop cross mobile OS apps - and using HTML/JS then you may consider Titanium Appcelerator or PhoneGap
         http://jonathanstark.com/blog/2010/04/05/phonegap-vs-titanium-mobile-et-al/
(initial impression is that Titanium is more focussed on IPhone/Android . But PhoneGap which provides little framework is truly more portable)


Other related Blog:
You may click on my blog - http://mobile-web-html.blogspot.com/ for steps/tips on creating mobile website for android,iphone. (as not many users will like
to download apps - as they can use alarms/services to impact battery life)

You can click this : choose android phone/usage/tips link to learn(or go back) more about deciding on how to choose best android phone. (developers should prefer  phone that is easily rootable - to test
your app on different/upcoming android versions ). You may click here for droid incredible specific review/tips/usage.

19 comments:

  1. post some appinventor tutorials dear...and you can send us @ andsollution@gmail.com

    ReplyDelete
  2. Well said, I blog because I enjoy it. I try not to get caught up in the comparison game. It is a process and you really do have to call on your better angels at times, but the minute this stops being fun for me about iphone and application development. Thanks for this great post.

    ReplyDelete
  3. Android development are very famous for in the mobile era.

    The Team Android phenomenon is spreading like wildfire. Lots of people are turning to the openness and diversity of Android smartphones when choosing a mobile device. The iPhone boasts the most robust selection of apps, but many developers are now also creating software for the Android Market.

    ReplyDelete
  4. I wanted to make 3d games for indroid.
    but was having so many issues.
    but when i read your article in this the most is Tutorial of Indroid Game
    so it was easy for me to work.
    thanks for sharing this

    get a facebook fan page

    ReplyDelete
  5. By read your post I got a good idea about Android application development.This is one of the valuable post.
    Android app developers

    ReplyDelete
  6. You are address way to advance your business, peoples can calmly to accepted about your business or restaurant and to your business to be added

    Android developers

    ReplyDelete
  7. That's a good piece of code you posted here. And it'll be great to see some appinventor tutorials here. Regards, Thomas from android programming

    ReplyDelete
  8. Guys check this out..... If you have ideas on mobile apps for use on phones, submit ur apps a contest that gives you a chance to prove your mettle. Whether you are a professional developer or a student, every1 can submit their apps developed by using the Series 40 Web apps SDK and win.
    Register today to submit ur apps....
    http://bit.ly/ICUrkh

    ReplyDelete
  9. I would like to thankx for the efforts you have put in writing this site. I’m hoping the same high-grade post from you in the upcoming as well.

    ReplyDelete
    Replies
    1. android app development
      I have seen your android coding.Your coding is very interesting.Appreciate you sharing, great post.Really thank you! Fantastic.

      Delete
  10. Interesting Article.
    Hoping that you will continue posting an article having a useful information.


    Android Apps

    ReplyDelete
  11. Android Tutorial for Beginners learns android programming and how to develop android mobile phone and ipad applications starting from environment setup.

    ReplyDelete
  12. Wow…can I really make money from home? What an idea and the best that I’ve heard in ages. Your website is cool and fun, and your blog is wonderful. I am very happy that I came across your write-up. Now, I am all set to take your advice and make my life worth living as a freelancer. Who would have thought that I am also an eligible candidate. I am sure to visit sell my creative graphic design,superb logo design that are open to people like me. Kudos!

    ReplyDelete
  13. I surprise how much effort you put to create such a great informative website! Android Game Development

    ReplyDelete