Bruce Scharlau, University of Aberdeen, 2010Google AndroidMobile ComputingBased on android-sdk_2.2
Bruce Scharlau, University of Aberdeen, 2010Android is part of the ‘build abetter phone’ processOpen Handset Alliance prod...
Bruce Scharlau, University of Aberdeen, 2010Android is growinghttp://metrics.admob.com/wp-content/uploads/2010/06/May-2010...
Bruce Scharlau, University of Aberdeen, 2010Android makes mobile Java easierhttp://code.google.com/android/goodies/index.h...
Bruce Scharlau, University of Aberdeen, 2010Android applications are writtenin Javapackage com.google.android.helloactivit...
Bruce Scharlau, University of Aberdeen, 2010Android applications arecompiled to Dalvik bytecodeWrite app in JavaWrite app ...
Code for intent passingmessagesBruce Scharlau, University of Aberdeen, 2010
First activity• Button search = (Button) findViewById(R.id.btnSearch);search.setOnClickListener(new View.OnClickListener()...
Second activity• @Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentVi...
Bruce Scharlau, University of Aberdeen, 2010The Dalvik runtime is optimisedfor mobile applicationsRun multiple VMs efficie...
Bruce Scharlau, University of Aberdeen, 2010Android has many components
Can assume that most haveandroid 2.1 or 2.2Bruce Scharlau, University of Aberdeen, 2010http://developer.android.com/resour...
Bruce Scharlau, University of Aberdeen, 2010Android has a working emulator
Bruce Scharlau, University of Aberdeen, 2010All applications are written inJava and available to each otherAndroid designe...
Bruce Scharlau, University of Aberdeen, 2010Android applications havecommon structureViews such aslists, grids, textboxes,...
Bruce Scharlau, University of Aberdeen, 2010Android applications havecommon structureBroadcastreceivers cantrigger intents...
Bruce Scharlau, University of Aberdeen, 2010There is a common file structurefor applicationscodeimagesfilesUI layoutsconst...
Bruce Scharlau, University of Aberdeen, 2010Standard components formbuilding blocks for Android appsOther applicationsHas ...
Bruce Scharlau, University of Aberdeen, 2010The AndroidManifest listsapplication details<?xml version="1.0" encoding="utf-...
Bruce Scharlau, University of Aberdeen, 2010Activity is one thing you can doFrom fundamentals page in sdk
Bruce Scharlau, University of Aberdeen, 2010Intent provides late runningbinding to other appsIt can be thought of as the g...
Bruce Scharlau, University of Aberdeen, 2010Services declared in the manifestand provide supportServices run in the backgr...
Bruce Scharlau, University of Aberdeen, 2010Notifications let you know ofbackground eventsThis way you know that an SMS ar...
Bruce Scharlau, University of Aberdeen, 2010ContentProviders share dataYou need one if your application shares datawith ot...
Bruce Scharlau, University of Aberdeen, 2010UI layouts are in Java and XMLsetContentView(R.layout.hello_activity); //will ...
Bruce Scharlau, University of Aberdeen, 2010Security in Android followsstandard Linux guidelinesEach application runs in i...
Upcoming SlideShare
Loading in...5
×

Google Android Mobile Computing

245

Published on

Google Android Mobile Computing

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

No notes for slide

Transcript of "Google Android Mobile Computing"

  1. 1. Bruce Scharlau, University of Aberdeen, 2010Google AndroidMobile ComputingBased on android-sdk_2.2
  2. 2. Bruce Scharlau, University of Aberdeen, 2010Android is part of the ‘build abetter phone’ processOpen Handset Alliance producesAndroidOpen Handset Alliance producesAndroidComprises handset manufacturers,software firms, mobile operators, andother manufactures and fundingcompaniesComprises handset manufacturers,software firms, mobile operators, andother manufactures and fundingcompanieshttp://www.openhandsetalliance.com/
  3. 3. Bruce Scharlau, University of Aberdeen, 2010Android is growinghttp://metrics.admob.com/wp-content/uploads/2010/06/May-2010-AdMob-Mobile-Metrics-Highlights.pdfDoes not include iTouch or iPad, as not smartphonesUneven distribution of OS by regions
  4. 4. Bruce Scharlau, University of Aberdeen, 2010Android makes mobile Java easierhttp://code.google.com/android/goodies/index.htmlWell, sort of…
  5. 5. Bruce Scharlau, University of Aberdeen, 2010Android applications are writtenin Javapackage com.google.android.helloactivity;import android.app.Activity;import android.os.Bundle;public class HelloActivity extends Activity {public HelloActivity() {}@Overridepublic void onCreate(Bundle icicle) {super.onCreate(icicle);setContentView(R.layout.hello_activity);}}
  6. 6. Bruce Scharlau, University of Aberdeen, 2010Android applications arecompiled to Dalvik bytecodeWrite app in JavaWrite app in JavaCompiled in JavaCompiled in JavaTransformed to Dalvik bytecodeTransformed to Dalvik bytecodeLinux OSLinux OSLoaded into Dalvik VMLoaded into Dalvik VM
  7. 7. Code for intent passingmessagesBruce Scharlau, University of Aberdeen, 2010
  8. 8. First activity• Button search = (Button) findViewById(R.id.btnSearch);search.setOnClickListener(new View.OnClickListener() {public void onClick(View view) {Intent intent = new Intent(Search.this, SearchResults.class);Bundle b = new Bundle();EditText txt1 = (EditText) findViewById(R.id.edittext);EditText txt2 = (EditText) findViewById(R.id.edittext2);b.putString("name", txt1.getText().toString());b.putInt("state", Integer.parseInt(txt2.getText().toString()));//Add the set of extended data to the intent and start itintent.putExtras(b);startActivity(intent);}});Bruce Scharlau, University of Aberdeen, 2010
  9. 9. Second activity• @Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.search_results);• Bundle b = getIntent().getExtras();int value = b.getInt("state", 0);String name = b.getString("name");TextView vw1 = (TextView) findViewById(R.id.txtName);TextView vw2 = (TextView) findViewById(R.id.txtState);vw1.setText("Name: " + name);vw2.setText("State: " + String.valueOf(value));}Bruce Scharlau, University of Aberdeen, 2010
  10. 10. Bruce Scharlau, University of Aberdeen, 2010The Dalvik runtime is optimisedfor mobile applicationsRun multiple VMs efficientlyRun multiple VMs efficientlyEach app has its own VMEach app has its own VMMinimal memory footprintMinimal memory footprint
  11. 11. Bruce Scharlau, University of Aberdeen, 2010Android has many components
  12. 12. Can assume that most haveandroid 2.1 or 2.2Bruce Scharlau, University of Aberdeen, 2010http://developer.android.com/resources/dashboard/platform-versions.html
  13. 13. Bruce Scharlau, University of Aberdeen, 2010Android has a working emulator
  14. 14. Bruce Scharlau, University of Aberdeen, 2010All applications are written inJava and available to each otherAndroid designed to enable reuse ofcomponents in other applicationsAndroid designed to enable reuse ofcomponents in other applicationsEach application can publish itscapabilities which other apps can useEach application can publish itscapabilities which other apps can use
  15. 15. Bruce Scharlau, University of Aberdeen, 2010Android applications havecommon structureViews such aslists, grids, textboxes, buttons,and even anembeddable webbrowserViews such aslists, grids, textboxes, buttons,and even anembeddable webbrowserContentProviders thatenableapplications toaccess data fromother applications(such asContacts), or toshare their owndataContentProviders thatenableapplications toaccess data fromother applications(such asContacts), or toshare their owndataA Resource Manager,providing access to non-code resources such aslocalized strings,graphics, and layout filesA Resource Manager,providing access to non-code resources such aslocalized strings,graphics, and layout filesA Notification Managerthat enables all apps todisplay custom alerts in thestatus barA Notification Managerthat enables all apps todisplay custom alerts in thestatus barAn Activity Manager thatmanages the life cycle ofapplications and providesa common navigationbackstackAn Activity Manager thatmanages the life cycle ofapplications and providesa common navigationbackstack
  16. 16. Bruce Scharlau, University of Aberdeen, 2010Android applications havecommon structureBroadcastreceivers cantrigger intents thatstart an applicationBroadcastreceivers cantrigger intents thatstart an applicationData storageprovide data foryour apps, andcan be sharedbetween apps –database, file,and sharedpreferences(hash map) usedby group ofapplicationsData storageprovide data foryour apps, andcan be sharedbetween apps –database, file,and sharedpreferences(hash map) usedby group ofapplicationsServices run in thebackground and haveno UI for the user –they will update data,and trigger eventsServices run in thebackground and haveno UI for the user –they will update data,and trigger eventsIntents specify whatspecific action should beperformedIntents specify whatspecific action should beperformedActivity is the presentationlayer of your app: there willbe one per screen, and theViews provide the UI to theactivityActivity is the presentationlayer of your app: there willbe one per screen, and theViews provide the UI to theactivity
  17. 17. Bruce Scharlau, University of Aberdeen, 2010There is a common file structurefor applicationscodeimagesfilesUI layoutsconstantsAutogeneratedresource list
  18. 18. Bruce Scharlau, University of Aberdeen, 2010Standard components formbuilding blocks for Android appsOther applicationsHas life-cyclescreenApp to handle contentBackground appLike music playerViewsmanifestActivityIntentsServiceNotificationsContentProviders
  19. 19. Bruce Scharlau, University of Aberdeen, 2010The AndroidManifest listsapplication details<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.my_domain.app.helloactivity"><application android:label="@string/app_name"><activity android:name=".HelloActivity"><intent-filter><action android:name="android.intent.action.MAIN"/><categoryandroid:name="android.intent.category.LAUNCHER"/></intent-filter></activity></application>
  20. 20. Bruce Scharlau, University of Aberdeen, 2010Activity is one thing you can doFrom fundamentals page in sdk
  21. 21. Bruce Scharlau, University of Aberdeen, 2010Intent provides late runningbinding to other appsIt can be thought of as the glue betweenactivities. It is basically a passive datastructure holding an abstract description ofan action to be performed.Written as action/data pairs such as:VIEW_ACTION/ACTION content://contacts/1Written as action/data pairs such as:VIEW_ACTION/ACTION content://contacts/1
  22. 22. Bruce Scharlau, University of Aberdeen, 2010Services declared in the manifestand provide supportServices run in the background:Music player providing the music playing inan audio applicationServices run in the background:Music player providing the music playing inan audio applicationIntensive background apps, might need tospawn their own thread so as to not blockthe applicationIntensive background apps, might need tospawn their own thread so as to not blockthe application
  23. 23. Bruce Scharlau, University of Aberdeen, 2010Notifications let you know ofbackground eventsThis way you know that an SMS arrived,or that your phone is ringing, and theMP3 player should pauseThis way you know that an SMS arrived,or that your phone is ringing, and theMP3 player should pause
  24. 24. Bruce Scharlau, University of Aberdeen, 2010ContentProviders share dataYou need one if your application shares datawith other applicationsYou need one if your application shares datawith other applicationsThis way you can share the contact list with theIM applicationThis way you can share the contact list with theIM applicationIf you don’t need to share data, then you canuse SQLlite databaseIf you don’t need to share data, then you canuse SQLlite database
  25. 25. Bruce Scharlau, University of Aberdeen, 2010UI layouts are in Java and XMLsetContentView(R.layout.hello_activity); //will load the XML UI file
  26. 26. Bruce Scharlau, University of Aberdeen, 2010Security in Android followsstandard Linux guidelinesEach application runs in its own processEach application runs in its own processProcess permissions are enforced at userand group IDs assigned to processesProcess permissions are enforced at userand group IDs assigned to processesFiner grained permissions are thengranted (revoked) per operationsFiner grained permissions are thengranted (revoked) per operations<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.google.android.app.myapp" ><uses-permission id="android.permission.RECEIVE_SMS" /></manifest><manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.google.android.app.myapp" ><uses-permission id="android.permission.RECEIVE_SMS" /></manifest>

×