Basic, Basic, Basic Android

flosssnailsMobile - Wireless

Dec 10, 2013 (3 years and 10 months ago)

58 views

Basic, Basic, Basic Android

What are Packages?


Page 346 in text


Package statement goes before any import statements


Indicates that the class declared in the file is part of the
specified package.


Convention for naming packages


Starts with Internet domain in reverse order


edu.uta.davis.packagename
;


Compile the package class


javac


d . FileName.java


Import package into programs


Import
edu.uta.davis.packagename
;

What is XML?


Extensible Markup Language


set of rules for
encoding documents electronically


Helps identify structures in documents


Can invent own tags


Not HTML


HTML tags are fixed


displays data


XML is a meta
-
language


transport and stores
data

<bookstore>



<book category="CHILDREN">



<title>Harry Potter</title>



<author>J K. Rowling</author>



<year>2005</year>



<price>29.99</price>



</book>



<book category="WEB">



<title>Learning XML</title>



<author>Erik T. Ray</author>



<year>2003</year>



<price>39.95</price>



</book>

</bookstore>

Main Components in Android
Application


Activities


building block of user interface;
analogous to dialog box or window


Content providers


way to store data on device that
is accessible by multiple applications


Services


designed to run indefinitely, independent
of any activity (e.g., RSS feed, play back music


Intents


systems messages that can notify
applications of various events from hardware state
changes to incoming data to application events


Other Features


Storage


Network


Multimedia


Global positioning system


Phone services

What do you need?


Eclipse 3.5 (Galileo)


JDK 5 or JDK 6


Android SDK starter package


http://developer.android.com/sdk/index.html


Android development tools


Android Virtual Device


What does an Android Project Look
Like?


Project contents are in an Android package file
(.
apk
)


Root Directory


AndroidManifest.xml


default.properties


assets


bin


gen


src


res

Root Directory (cont)


AndroidManifest.xml


describes application being built and
which components are being supplied by the application


default.properties


used by built script


assets


holds other static files you want packaged with your
application


bin


folder that holds compiled code


gen


where Android’s tools will place source code they
generate


src
-

hold Java source code for application


res


holds resources that are packaged with the compiled
Java in the application (icons, GUI layouts, etc)


package com.example.helloandroid;


import android.app.Activity;

import android.os.Bundle;

import android.widget.TextView;


public class HelloAndroid extends Activity {


/** Called when the activity is first created. */


@Override


public void onCreate(Bundle savedInstanceState)
{


super.onCreate(savedInstanceState);


TextView tv =
new TextView(this);


tv.setText("Hello Android");


setContentView(tv);


}

}

<?xml version=
"1.0" encoding="utf
-
8"?>

<manifest xmlns:android=
"http://schemas.android.com/apk/res/android"


package=
"com.example.helloandroid"


android:versionCode=
"1"


android:versionName=
"1.0">


<application android:icon=
"@drawable/icon"
android:label="@string/app_name">


<activity android:name=
".HelloAndroid"


android:label=
"@string/app_name">


<intent
-
filter>


<action android:name=
"android.intent.action.MAIN" />


<category
android:name=
"android.intent.category.LAUNCHER" />


</intent
-
filter>


</activity>


</application>

</manifest>