Saturday, June 14, 2014

Android Applications Development in 15min (tutorial 02)

Last Post (tutorial 01) was on Android Software Stack and Terminology[1]. This post will for beginner on Android applications, This post will teach you fast mobile application development from Android Developer Tools (ADT) are based on the Eclipse IDE.

1. Start ADT and then go file—> new –> Android Applications Project

image 

2. Follow the wizard with give project name (other values can be defaults as it is)

3. You will get below project structure

image

4. As below UI, you can drag and drop text-edit and button

image

In this sample we will added button action to pick text in text-field that mobile user entering to to above text label to show.

5.  Go to text mode of above UI (res/layout/fragment_main.xml) and added below line to button, to pick action when button is click

android:onClick="sendMessage"

6. Then write a function in MainActivity.java in 'src'

1 ** Called when the user touches the button */
2 public void sendMessage(View view) {
3 // Do something in response to button click
4 }

7. No we will write code to read string on text-field and added to text label


1 /** Called when the user touches the button */
2 public void sendMessage(View view) {
3 // Do something in response to button click
4 EditText editText = (EditText) findViewById(R.id.editText1);
5 TextView textView = (TextView) findViewById(R.id.textView1);
6 //getting string from edit text field
7 String name = editText.getText().toString();
8 //adding string to text view / text label
9 textView.setText(name);
10 }

8. Now run application in phone and see is it work as we expecting. You can use hardware device to run it for test even also and this post it how to ‘Using Hardware Devices to Run Android App from IDE’[2]
image


9. Now we will look on real device, yes it is work as we needed


Screenshot_2014-06-15-11-18-05[1] 


10. Log message also to know, simple. You can added log as below to you java method


Log.v("EditText", editText.getText().toString());


[NOTE]



  • tag: Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs

  • msg: The message you would like logged

Log filtering can be done by



  • ASSERT    - The println method.

  • DEBUG    - The println method; use Log.d.

  • ERROR    - The println method; use Log.e.

  • INFO    - The println method; use Log.i.

  • VERBOSE    - The println method; use Log.v.

  • WARN    - The println method; use Log.w.

Here I am looking console log from PC


image


 


[1] http://madhukaudantha.blogspot.com/2014/06/android-software-stack-and-terminology.html
[2]http://madhukaudantha.blogspot.com/2014/06/using-hardware-devices-to-run-android.html

3 comments:

  1. Android application development is ideal for all kinds of inter-application integration. In a situation where you have several programs and wish to combine or cross-promote these, Android is an ideal platform.

    ReplyDelete
  2. Good to share the amazing application platform. You can get Gaming applications from www.apkdig.com

    ReplyDelete