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
Harry Potter J K. Rowling Learning XML Erik T. Ray
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 – 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. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello Android"); setContentView(tv); } <manifest xmlns:android=" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0"> <activity android:name=".HelloAndroid"