Sunday 2 October 2011

Mobile Phone Application on Android Platform

Android is an open-source mobile phone operating system by Google. In the recent past about 40% of the total smartphone users prefers android over any other operating system available for mobile phones. Android being open-source allows programmers and developers from all around the world to develop applications and the software’s source code.
Google Android Logo :-  (Source:-google)

Google Labs and Google Codes even provide many APIs, software and applications to help users to create their own applications and games with the help of blocks and even with the use of simple programming language like python. Users with no programming knowledge can create android application using app-inventor and the one with programming knowledge can use scripting language like python for their ease of work.

Our love for android was one of the main reasons to take Android Application as our learn-it-yourself activity. Also, creating an application for the phone we use is a little inspiring. Though it’s a little challenging task but creating your own application is worth it.

Google App-Inventor
Google Appinventor is online software which helps users to create their own application using an emulator or a connected android phone. The Appinventors servers provide many APIs allowing user to create applications that are two hard to create when it comes to actually coding them. This online software is still in a beta (testing) mode and is available and accessed through http://www.appinventorbeta.com . The website provides many tutorials which helps the user to understand the use of different functions in a lot easier and experimental way.

To start with the appinventer you need to install appinventer setup, a latest version of chrome, Firefox or IE and latest java platform on your computer. You can get the setup for appinventer from the website and the setup for java is can be downloaded from this link. When you are ready with this, what you all need is try to attempt all the basic tutorials given in the Learn Portion on the website. This will give you an idea about using the drag and drop components system and the basic knowledge to use the block editor.

As App-Inventor is still in its beta it only allows user to create single screen applications. All the components like buttons, labels, canvas, lists etc. are needed to be added on this screen and managed accordingly. These components can be visible or invisible that is some of the components like local (tinyDB) and web (webDB) databases come under the invisible components.

The main screen when we open the appinventor website

The next tool we need to use is the Block Editor, The Block Editor allow user to give logical conditions and attach all the components added in the screen. You can create variables, functions and higher programming stuff with the help of dragging and dropping the blocks.

The Block Editor


While learning the basic functionality of App-Inventor we went through the basic tutorials, and then decided to create a basic game which is all about testing the reaction time of your brain. We named it ReFlExEs. We used a canvas(Basic Component)  and a ball(Animation Component)to make the game. Each time the ball is clicked the position of the ball on canvas is randomized and the size is changed. Our main focus was on using a single screen as multiple screens. We use the component visibility function and toggled the visibility of the arrangement as required and use the arrangements as different screens. There were many problems that came in between the completion of the application, one of them was dealing with tinyDB which is local database created in the phone once you install the application. The problem we were facing was the initialization of the variable. . But with the help of our seniors and a new logical block it was overcome easily. At the end of it, we were able to include the following in our application:-


1.A main menu which is able to lead us to three other pages.
2.A score screen where you can see the last score and the all time score.
3.A help Page.
4.Add a function which changes the color of the ball each time it is touched.
5.Limited the time to 10 seconds.
6.A vibrate whenever a ball is touched.
7.The score incrementing and decrementing function.


This is the block diagram of the application we created.


After defining all the variables, functions and logics in the block editor you need to test it on a connected phone or emulator. You can create an emulator with the help of the New Emulator button on the top.


New Emulator and Connect to device on the top


The Android Emulator:- just like a usual android phone

After creating the emulator you can connect to it with the Connect To device button. After the connection is made this is what a emulator looks like.


Our application on the Emulator

After trying the application on emulator as well as on our phone, we finally decided to pack our application into .apk format.

After Installing the application on your phone. The application can be seen in the main application menu. You can download our application by scanning the following QR code in your android phone.



You need to select an icon just to make sure that your app is identifiable and unique. App-Inventor provides many ways to share this application one of them is sharing it with a QR code or downloading it to your computer. You can also directly download it to your phone.

Scripting in Python language
The other and a more precise way to create Android Applications is by scripting in python language. All you need is a little python knowledge and an android phone to run those scripts. As we all know python is one of the easiest programming languages, it makes it really easy to use the hardware as well as software components of the Operating System.

To start with the scripting all you need to install a few applications on your phone and start with it. The first and the most important application you need to install is SL4A- Scripting Layer for Android. The next application you have to install is Python for Android and then any text editor from Android Market.


These are the two applications you need to install on your android phone.




After installing these two applications you need to import and install all the latest modules available in the Python for Android. For basic application you do not need the advance modules. You can just go with installing the default modules.


To start adding your scripts you need to go to sl4a and in the options select Add. In the pop-out menu select Python Script and you can go ahead with your scripting. 



For starting with the python script you need to import android into the py file and declare a variable equals to Android.android( ). after that you can go with the basic commands and the one provided in the APIs. 


We thought of different ideas but at last we chose a script which shows you all the battery information. Our app is capable of giving the following Information:-
1. Battery Condition
2. Battery Level
3. Battery Temperature
4. Battery Voltage
5. Battery Charging Information
6. Battery PlugType


You can view our script from this link. You can use the basic GUI from sl4a.

You can also share your python scripts in .apk format instead of the default .py format. This can be done with the help of Eclipse IDE or even with the use of ANT. For complete step-wise instruction you can go here.

The .apk application you create can be shared with your friends through different medium. You can mail them or even upload it on the android market once you buy an account over there. To start with the best way is to create an application according to your requirement.

For more reference:
App-Inventor
SL4A
Android dovelopers

Hope you enjoy developing applications for your phone and for ours. For any query comment below and we will try our level best to solve those queries.

Anant Rana-2011018
Siddharth Gupta-2011110


No comments:

Post a Comment