Download Android dev

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Android
N Amanquah
Application Framework





Views (extensible) -to build an application, including lists,
grids, text boxes, buttons, an embeddable web browser etc
Content Providers allow access to data from other
applications (eg Contacts), or share their own data
Resource Manager, provides access to non-code resources
eg localized strings, graphics, and layout files
Notification Manager enables applications to display custom
alerts in the status bar
Activity Manager manages lifecycle of applications and
provides a common navigation backstack
Another classification

Four types of application components
• activity represents a single screen with a user
interface.
• service is a component that runs in the
background
• content provider manages a shared set of
application data
• broadcast receiver is a component that
responds to system-wide broadcast
announcements.
Android


Comes with some apps eg sms, email client,
calendar, contacts, maps etc.
Apps are written in Java
See http://developer.android.com/guide/basics/what-is-android.html
Each Android app runs in its own process, (own instance Dalvik virtual machine.). The
Dalvik VM executes files in the Dalvik Executable (.dex) format
Install Android SDK


Download and install SDK starter pkg (eg installer_r10-windows.exe )
Obtain the android platform and other tools tools
• (using Android SDK & AVD Manager)
 Automatically downloads. (Run “android” in tool directory)
 "Android SDK and AVD Manager" available package and right
panel. Find available version and samples package. Select and
install.
• w/o internet connection:
 Visit http://dl-ssl.google.com/android/repository/repository.xml
 Eg, to download MAC version of android v 2.0: http://dlssl.google.com/android/repository/android-2.0_r01-macosx.zip
(note the paths)
 unzip into appropriate folder
 Open "Android SDK and AVD Manager" , refresh packages
• Ref: http://qdevarena.blogspot.com/2010/05/download-android-sdkstandalone-for.html
Setup & Development



Eclipse preferred.
For netbeans, obtain nbandroid plugin.
Installation options:
• Use update center: Tools->Plugins->Settings tab,
update center
• http://kenai.com/downloads/nbandroid/updates.xml
• Alt: download the plugin eg Eg nbandroid-1.3beta
•




http://kenai.com/projects/nbandroid/downloads
Add Android Platfom after installing the plugins. Go to
ToolsJava Platforms
specify sdk location eg
C:\Program Files\Android\android-sdk
Package name should have two parts separated by a dot. Also select the target
platform (create one using android SDK & AVD manager)



An activity is a single, focused thing that the user
can do
Activities interact with the user, creates a window
Two methods to implement for Activity
• OnCreate(Bundle) is where you initialize your activity. eg
defining your UI, and use findViewById(int) to
programatically retrieve widgets in UI .
• onPause() -user leaves activity. commit changes


Start an activity (or give it something new to do)
by passing an Intent to startActivity() or
startActivityForResult()
activities, services, and broadcast receivers—are activated by an
asynchronous message called an intent
Basic Apps

Hello World – (default)
package nna.pkg1;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Customize View

Change strings in main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, MainActivity"
/>
</LinearLayout>
Localization: strings.xml




<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MainActivity</string>
</resources>
Refs


Building apps using command line tools
• http://developer.android.com/guide/developing
/projects/projects-cmdline.html
The android manifest file
• http://developer.android.com/guide/topics/ma
nifest/manifest-intro.html