Your SlideShare is downloading. ×
Introduction to Android
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Introduction to Android

715
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
715
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to Android
  • 2. Challenges • Small screens • CPU memory and speed are tight • Programming languages and frameworks are dependent on the device manufacturer’s support • Applications must not interfere with phone system
  • 3. Android • Eclipse development • Java programming language • Framework for phone applications • Every application runs in its own Linux process
  • 4. Android Components • Activity – Similar to a window or dialog in a desktop application – Each activity is given a default window to draw in – An application may consist of one or more activities – Visual content is provided by a hierarch of View objects • Content Provider – Provides access to data
  • 5. Android Components • Services – Long running applications such as checking for updates on an RSS feed • Broadcast Receiver – Receives and reacts to broadcast announcements such as battery low, picture taken – Extend BroadcastReceiver base class – Can start an activity in response to information or use the NotificationManager to aler the user through vibrating the device, playing a sound, etc.
  • 6. Intent • Asynchronous messages • Intent object holds the content of the message – Activities are launched or activated by papassing an Intent object to Context.startActivity – Services are started by passing an Intent object ot Context.startService() – A broadcast can be initiated by passing an Intent object to Context.sendBroadcast()
  • 7. AndroidManifest.xml • Describes the application and the components available – <activity>, <service>, and <receiver> tags • Names libraries needed • Identifies permissions the application expects to be granted <?xml version="1.0" encoding="utf-8"?> <manifest . . . > <application . . . > <activity android:name="com.example.project.FreneticActivity" android:icon="@drawable/small_pic.png" android:label="@string/freneticLabel" ... > </activity> ... </application> </manifest>
  • 8. Saying Hello to the World • Create an Android Virtual Device (AVD) – Choose Window->Android SDK and AVD Manager – Select Virtual Devices in the left panel – Click New, the Create New AVD dialog appears – Type the name of the AVD such as “my_avd” – Choose a target – Click Create AVD
  • 9. Saying Hello to the World • Create a New Android Project – Select File->New->Project->Android – Select “Android Project” and click Next – Fill in the Project Details: • Project Name: HelloAndroid • Application Name: Hello, Android • Package Name: edu.adams.cs250 • Create Activity: HelloAndroid – Click Finish
  • 10. HelloAndroid Called when Android •User interacts with one Activity at a time. starts the Activity •Not required to have a UI but it usually does public class HelloAndroid extends Activity { public void onCreate( Bundle savedInstanceState ){ super.onCreate(savedInstanceState); setContentView( R.layout.main); } }
  • 11. Saying Hello to the World • Add view objects – Drawable objects that •An Activity inherits from Context are subclasses of View •A Context is a handle to the system that can be used to obtain access to databases and user preferences TextView tv = new TextView( this ); tv.setText( “Hello, Android”); setContentView( tv ); Sets the view for the Activity
  • 12. XML Layout • Programmatic UI can be time-consuming to build •Save in res/layout/main.xml •For landscape layout, save • Difficult to change the file in res/layout-land <TextView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=“fill_parent” •How much of the screen width android:layout_height=“fill_parent” the view should consume •Since it is the only view, it will android:text=“@string/hello”/> take up the entire screen •The resource to use to find the text of the button •File is located in res/values/strings.xml •Provides internationalization support
  • 13. Strings.xml <resources> <string name=“hello”>Hello Android!</string> <string name=“app_name”>Hello, Android</string> </resources>
  • 14. Activity Modification public void onCreate( Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); }