1 / 15

Introduction to Android

Introduction to Android. CS420 – Spring 2010. Android. What is Android Custom Linux Distribution and Java-based Virtual Machine Based on the Java language 1.5 standard Java is an overloaded term. It refers to: A language with a distinct syntax/grammar A class library

yamin
Download Presentation

Introduction to Android

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Android CS420 – Spring 2010

  2. Android • What is Android • Custom Linux Distribution and Java-based Virtual Machine • Based on the Java language 1.5 standard • Java is an overloaded term. It refers to:A language with a distinct syntax/grammar • A class library • A stack based virtual machine • Android has implemented their own VM called Dalvik. Dalvik is different because it uses a register based VM architecture. • The practical consequence of the decision to drop the Java VM is standard java classes cannot be used on android without conversion.

  3. Lab 3 • SDK Demo & Tools Overview • Eclipse Plugin • DDMS

  4. Activity class • Roughly corresponds to a single “screen” • Your application’s entry point. • Does not require a user interface, but that would be atypical. • When a new screen opens, the previous screen is paused and put onto a history stack. The user can then navigate backwards through previously opened screens in the history. Screens can also be removed from the history stack when it would be inappropriate for them to remain.

  5. Service class • Application component that runs in the background, for an indefinite period of time. • OpenBinder –System Level IPC and Component Framework • Local Services and Remote Services • Remote Services require using aidl and Parcelable classes

  6. Activity or Service Blocking • Use Threads liberally. • If your application or service blocks, the ActivityManager will come over and throw up a nasty ANR error for Application Not Responding.

  7. Intent class • An intent is a description of an operation to be performed. • It can be used with Activity.startActivity()to launch an Activity orContext.BindService() to communicate with aService. It can be broadcast system-wide to send it to any interested BroadcastReceivercomponents

  8. Intent Example • Intent myIntent = new Intent( • android.content.Intent.ACTION_VIEW, • Uri.parse("geo:38.899533,-77.036476") • ); • startActivity(myIntent); • Will open up the Maps Activity with the specified coordinates.

  9. BroadcastReceiver • A means to respond to system level events • The interface consists of a single method: • onReceive() { } • To use in your Activity: • registerReceiver()in your Activity’s onResume()callback • unRegisterReceiver()in your Activity’s onPause()method • You can’t use it as an arbitrary message bus, because it will miss messages when the it’s Activity is inactive. • This holds even if you fail to unregister the receiver. Unregistering the receiver is merely good practice that reduces the system overhead by a small amount.

  10. Content Provider • A means for sharing tabular data across applications • It is a class that implements a standard set of methods to let other applications store and retrieve the type of data that is handled by that content provider. • Uses sqlite backend for relational data storage

  11. Android User Interface • May be defined using XML files or by writing standard java code • XML CaveatsThe XML parser and renderer have a lot of bugs. This crashes eclipse alot. • <?xml version="1.0" encoding="utf-8"?> • <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent“ android:layout_height="fill_parent"> • <TextViewandroid:layout_width="wrap_content" android:layout_height="wrap_content“ android:text="Hello World"/> • </LinearLayout>

  12. Layouts • FrameLayoutcontains a single object • LinearLayoutaligns all children in a single direction • TableLayoutpositions its children into rows and columns • AbsoluteLayoutabsolute positioning • RelativeLayout • children specify their position relative to the parent view or to each other

  13. Handling UI events • Handle events the standard way: • EventListenersonClick() • EventHandlersonTouchEvent(MotionEvent)

More Related