SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Android 101Introduksjon til Android Truls Jørgensenog Are Wold 8. september 2010
Truls Are
Bidragsyterefra Android fokusgruppe Hans Petter Eide Knut BjørnarWålberg © 2010 Capgemini. All rights reserved. 3
Agenda © 2010 Capgemini. All rights reserved.
Bakgrunn Android kjøpesoppav Google i 2005  Googlesmotivasjon "Bedretjenesterogbrukeropplevelsepåmobilgirmermobilnettbrukogmerpengerireklamekassatil Google" (Computerworld UK) "Merinnovasjonpå mobile plattformer", "The world was broken"-  Rich Miner, Google  Sidekick T-Mobile G1 / HTC Dream Nexus One © 2010 Capgemini. All rights reserved.
Android! "The first truly open and comprehensive platform for mobile devices, all of the software to run a mobile phone but without the proprietary obstacles that have hindered mobile innovation" - Andy Rubin, Google  © 2010 Capgemini. All rights reserved.
© 2010 Capgemini. All rights reserved.
! Android… © 2010 Capgemini. All rights reserved.
Business case - markedsandeler 13% 13% 3% 17% © 2010 Capgemini. All rights reserved.
Utviklingsverktøy og dokumentasjon Tilgjengeligeutviklingsplattformer Eclipse, SDK Emulator, ADB, SQLite Debugging på device Dalvik debug monitor - tilstandpåenheten LogCat Online API reference, Java style http://developer.android.com © 2010 Capgemini. All rights reserved.
..and now for somethingcompletelydifferent!
JZinema BETA! (butreleasingon time) © 2010 Capgemini. All rights reserved.
Byggeklosser  i Android © 2010 Capgemini. All rights reserved.
Byggeklosser  i Android © 2010 Capgemini. All rights reserved.
Intent Intent Activities og intents © 2010 Capgemini. All rights reserved. Intent MovieListActivity MovieDetailActivity (eksterne Activities)
Skjermbilder © 2010 Capgemini. All rights reserved.
Fra XML til Java © 2010 Capgemini. All rights reserved. // res/layout/movie_list.xml <Button android:id="@+id/select_city_button“  android:textSize="20dp” /> // R.java  public static final class id {      (…)      public static final intselect_city_button=0x7f070016;  } // MovieListActivity.java  mCinemaButton = (Button) findViewById(R.id.select_city_button);
MovieList.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF"  	  (…) 	 	  <Button android:id="@+id/movie_list_cinema"  android:textSize="20dp" android:background="@drawable/select_city_button" android:text=“@string/select_city_text“ /> </LinearLayout> Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved. res/values/string.xml: (…) <stringname=”select_city_text">Velgby</string>
Activity – MovieListActivity.java publicclassMovieListActivityextendsListActivity { 	(…) /** Called when the activity is first created. */ @Override publicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.movie_list); mMovieListHeader = (TextView) findViewById(R.id.movie_list_header); currentCity = getSelectedCity(); mMovieListHeader.setText( getString(R.string.header_text_now_showing_in) + currentCity); updateMoviesForCity(currentCity); 	   (…) 	} } Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
Byggeklosser  i Android © 2010 Capgemini. All rights reserved.
Kommunikasjonmellomkomponenter ,[object Object]
Starte en Activity – spesifisert, eller ikke
Sende en melding til systemet
Starte eller koble på en Service© 2010 Capgemini. All rights reserved.
Intents mellom activites © 2010 Capgemini. All rights reserved. // MovieListActivity.java final Intent intent = new Intent(this, MovieDetails.class); intent.putExtra(MoviesProvider._ID, id); startActivity(intent); // MovieDetailsActivity.java finalIntentintent = getIntent(); long id = intent.getExtras().getLong(MoviesProvider._ID); Insert "Title, Author, Date"
Intents mellom applikasjoner © 2010 Capgemini. All rights reserved. // MovieDetailsActivity.java final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(buyTicketLink)); startActivity(intent); // MovieDetailsActivity.java final Intent intent= new Intent(Intent.ACTION_VIEW); intent.setDataAndType(   	Uri.parse(mMovieDetailsTrailerUrl),"video/*"); startActivity(intent);
Byggeklosser  i Android © 2010 Capgemini. All rights reserved.
Content Provider Wrapper rundt en datakilde For data somønskestilbudttilandreapplikasjoner (egentlig)  Standardiserttilgangtil data vha CONTENT_URI: content://no.jzinema.provider.Movies/movies © 2010 Capgemini. All rights reserved.
Content Provider: Persistering © 2010 Capgemini. All rights reserved. Content Provider Sqlite DB // Lagre en film // CONTENT_URI: content://no.jzinema.provider.Movies/movies Uriuri = mContext.getContentResolver(). insert(MoviesProvider.CONTENT_URI, values);
Content Provider: Henting av data © 2010 Capgemini. All rights reserved. Content Provider Sqlite DB // MovieDetailsActiviy.java henter en film: //content://no.jzinema.provider.Movies/movies/5 Cursor c =  managedQuery(ContentUris.withAppendedId( MoviesProvider.CONTENT_URI, _id),          null, null, null, null); // MovieListActivity.java spør  // (blant annet) etter alle filmers id Cursor c = managedQuery(MoviesProvider.CONTENT_URI, COLUMN_ID, null, null, null);
MoviesContentProvider.java publicclassMoviesProviderextendsContentProvider { 	publicstaticfinal String AUTHORITY = "no.jzinema.provider.Movies"; publicstaticfinal Uri CONTENT_URI =  Uri.parse("content://" + AUTHORITY + "/movies"); @Override publicbooleanonCreate(…) @Override public Uri insert(…)  @Override 	public Cursor query(…) @Override 	publicint update(…) @Override 	publicint delete(…)  @Override 	public String getType(…) } Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
MovieListActivity: Cursor og CursorAdapter © 2010 Capgemini. All rights reserved. // Alle filmer i en by Cursor cursor = getContentResolver().query(   MoviesProvider.CONTENT_URI, COLUMNS, MovieConstants.ATTRIBUTE_ID + " IN (" + movieIds + ")", null, null); startManagingCursor(cursor); // Opprett et cursorAdaptersombenyttercursorentil å populerehverradi listen  mAdapter = newMovieListCursorAdapter (this, R.layout.movie_list_row, cursor, COLUMNS, VIEWS_IN_LIST_ROW); // ListActivitytrenger et adapter. this.setListAdapter(mAdapter); Content Provider Sqlite DB
DEMO: Live debugging Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
Byggeklosser  i Android © 2010 Capgemini. All rights reserved.
Konfigurering AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="no.capgemini.jzinema” android:versionCode="1” android:versionName="1.0"> <!-- Permissions --> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/icon" android:label="@string/app_name" 	android:debuggable="true"> 		<!-- Activity for showing a list of movies currently running in the cinemas--> 		<activity android:name=".MovieList“> 	         <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="no.capgemini.jzinema.SHOW_MOVIELIST" /> </intent-filter> </activity> <providerandroid:authorities="no.jzinema.provider.Movies“ android:name=".provider.MoviesProvider“ /> 	</application> <uses-sdkandroid:minSdkVersion=“4" /> </manifest> © 2010 Capgemini. All rights reserved.
AndroidManifest.xml  - utdrag <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="no.capgemini.jzinema” android:versionCode="1” android:versionName="1.0"> <!-- Permissions --> <uses-permission android:name="android.permission.INTERNET" /> 	 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <!-- Activity for showing a list of movies currently running in the cinemas. --> <activity android:name=".activity.movielist.MovieListActivity" android:label="@string/app_name" android:configChanges="orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <providerandroid:authorities="no.jzinema.provider.Movies“ android:name=".provider.MoviesProvider“ /> 	</application> <uses-sdkandroid:minSdkVersion=“4" /> </manifest> Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
Strukturen i en Android-app ligner på en webapp © 2010 Capgemini. All rights reserved.
Testing på Android © 2010 Capgemini. All rights reserved.
DEMO Robotium Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
Andre byggeklosser  i Android © 2010 Capgemini. All rights reserved.
En mobil har sine begrensninger Strøm Datatrafikk Begrenset hardware Cursors, liksom? Komplekse livssykluser Multitasking © 2010 Capgemini. All rights reserved.
Aktivitet starter Forenkletlivssyklus for en Activity onCreate() Bruker går tilbake til aktiviteten onStart() onRestart() onResume() Prosess drept Aktivitet kjører Aktivitet havner i forgrunnen Aktivitet havner i bakgrunnen Aktivitet havner i forgrunnen onSaveInstanceState() onPause() Lavt minne Aktiviteten er usynlig onStop() Aktivitet avsluttet Lavt minne, finish() onDestroy() © 2010 Capgemini. All rights reserved.
Ytelse foran alt ,[object Object]
Hissig GarbageCollection
Du veit aldri når’em kommer
Nettverk kan være tregt og dyrt
Tenk lokal caching
Trådhåndtering:

Weitere ähnliche Inhalte

Ähnlich wie Android101 : Introduksjon til Android

PhoneGap, Backbone & Javascript
PhoneGap, Backbone & JavascriptPhoneGap, Backbone & Javascript
PhoneGap, Backbone & Javascript
natematias
 
ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013
Mathias Seguy
 
iPhone/iPad Development with Titanium
iPhone/iPad Development with TitaniumiPhone/iPad Development with Titanium
iPhone/iPad Development with Titanium
Axway Appcelerator
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
Benjamin Cabé
 

Ähnlich wie Android101 : Introduksjon til Android (20)

Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
 
PhoneGap, Backbone & Javascript
PhoneGap, Backbone & JavascriptPhoneGap, Backbone & Javascript
PhoneGap, Backbone & Javascript
 
Automated testing of mobile applications on multiple platforms
Automated testing of mobile applications on multiple platformsAutomated testing of mobile applications on multiple platforms
Automated testing of mobile applications on multiple platforms
 
ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013
 
Android Workshop 2013
Android Workshop 2013Android Workshop 2013
Android Workshop 2013
 
Appcelerator iPhone/iPad Dev Con 2010 San Diego, CA
Appcelerator iPhone/iPad Dev Con 2010 San Diego, CAAppcelerator iPhone/iPad Dev Con 2010 San Diego, CA
Appcelerator iPhone/iPad Dev Con 2010 San Diego, CA
 
iPhone/iPad Development with Titanium
iPhone/iPad Development with TitaniumiPhone/iPad Development with Titanium
iPhone/iPad Development with Titanium
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Opticon 2015 - Getting Started with the Optimizely Developer Platform
Opticon 2015 - Getting Started with the Optimizely Developer PlatformOpticon 2015 - Getting Started with the Optimizely Developer Platform
Opticon 2015 - Getting Started with the Optimizely Developer Platform
 
UberFire Quick Intro and Overview (early beta Aug 2013)
UberFire Quick Intro and Overview (early beta Aug 2013)UberFire Quick Intro and Overview (early beta Aug 2013)
UberFire Quick Intro and Overview (early beta Aug 2013)
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
 
ハンズオン資料 電話を作ろう(v2.x用)
ハンズオン資料 電話を作ろう(v2.x用)ハンズオン資料 電話を作ろう(v2.x用)
ハンズオン資料 電話を作ろう(v2.x用)
 
Android is not just mobile
Android is not just mobileAndroid is not just mobile
Android is not just mobile
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Android - Open Source Bridge 2011
Android - Open Source Bridge 2011Android - Open Source Bridge 2011
Android - Open Source Bridge 2011
 
Top Tips for Android UIs
Top Tips for Android UIsTop Tips for Android UIs
Top Tips for Android UIs
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - South We...
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
 

Mehr von Truls Jørgensen

Mehr von Truls Jørgensen (9)

Optimising for Fast Flow in Norway's Largest Bureaucracy04042022.pdf
Optimising for Fast Flow in Norway's Largest Bureaucracy04042022.pdfOptimising for Fast Flow in Norway's Largest Bureaucracy04042022.pdf
Optimising for Fast Flow in Norway's Largest Bureaucracy04042022.pdf
 
Smidig i coronakrise
Smidig i coronakriseSmidig i coronakrise
Smidig i coronakrise
 
Continuous monitoring
Continuous monitoringContinuous monitoring
Continuous monitoring
 
Open source all the offentlig things
Open source all the offentlig thingsOpen source all the offentlig things
Open source all the offentlig things
 
Software er politikk
Software er politikkSoftware er politikk
Software er politikk
 
From 4 releases a year to once every other minute
From 4 releases a year to once every other minuteFrom 4 releases a year to once every other minute
From 4 releases a year to once every other minute
 
Alignment in the age of autonomy
Alignment in the age of autonomyAlignment in the age of autonomy
Alignment in the age of autonomy
 
The systems behind the best welfare state in the world
The systems behind the best welfare state in the worldThe systems behind the best welfare state in the world
The systems behind the best welfare state in the world
 
Systemene bak verdens beste velferdsstat
Systemene bak verdens beste velferdsstatSystemene bak verdens beste velferdsstat
Systemene bak verdens beste velferdsstat
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Android101 : Introduksjon til Android

  • 1. Android 101Introduksjon til Android Truls Jørgensenog Are Wold 8. september 2010
  • 3. Bidragsyterefra Android fokusgruppe Hans Petter Eide Knut BjørnarWålberg © 2010 Capgemini. All rights reserved. 3
  • 4. Agenda © 2010 Capgemini. All rights reserved.
  • 5. Bakgrunn Android kjøpesoppav Google i 2005 Googlesmotivasjon "Bedretjenesterogbrukeropplevelsepåmobilgirmermobilnettbrukogmerpengerireklamekassatil Google" (Computerworld UK) "Merinnovasjonpå mobile plattformer", "The world was broken"-  Rich Miner, Google Sidekick T-Mobile G1 / HTC Dream Nexus One © 2010 Capgemini. All rights reserved.
  • 6. Android! "The first truly open and comprehensive platform for mobile devices, all of the software to run a mobile phone but without the proprietary obstacles that have hindered mobile innovation" - Andy Rubin, Google  © 2010 Capgemini. All rights reserved.
  • 7. © 2010 Capgemini. All rights reserved.
  • 8. ! Android… © 2010 Capgemini. All rights reserved.
  • 9. Business case - markedsandeler 13% 13% 3% 17% © 2010 Capgemini. All rights reserved.
  • 10. Utviklingsverktøy og dokumentasjon Tilgjengeligeutviklingsplattformer Eclipse, SDK Emulator, ADB, SQLite Debugging på device Dalvik debug monitor - tilstandpåenheten LogCat Online API reference, Java style http://developer.android.com © 2010 Capgemini. All rights reserved.
  • 11. ..and now for somethingcompletelydifferent!
  • 12. JZinema BETA! (butreleasingon time) © 2010 Capgemini. All rights reserved.
  • 13. Byggeklosser i Android © 2010 Capgemini. All rights reserved.
  • 14. Byggeklosser i Android © 2010 Capgemini. All rights reserved.
  • 15. Intent Intent Activities og intents © 2010 Capgemini. All rights reserved. Intent MovieListActivity MovieDetailActivity (eksterne Activities)
  • 16. Skjermbilder © 2010 Capgemini. All rights reserved.
  • 17. Fra XML til Java © 2010 Capgemini. All rights reserved. // res/layout/movie_list.xml <Button android:id="@+id/select_city_button“ android:textSize="20dp” /> // R.java public static final class id { (…) public static final intselect_city_button=0x7f070016; } // MovieListActivity.java mCinemaButton = (Button) findViewById(R.id.select_city_button);
  • 18. MovieList.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF" (…) <Button android:id="@+id/movie_list_cinema" android:textSize="20dp" android:background="@drawable/select_city_button" android:text=“@string/select_city_text“ /> </LinearLayout> Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved. res/values/string.xml: (…) <stringname=”select_city_text">Velgby</string>
  • 19. Activity – MovieListActivity.java publicclassMovieListActivityextendsListActivity { (…) /** Called when the activity is first created. */ @Override publicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.movie_list); mMovieListHeader = (TextView) findViewById(R.id.movie_list_header); currentCity = getSelectedCity(); mMovieListHeader.setText( getString(R.string.header_text_now_showing_in) + currentCity); updateMoviesForCity(currentCity); (…) } } Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
  • 20. Byggeklosser i Android © 2010 Capgemini. All rights reserved.
  • 21.
  • 22. Starte en Activity – spesifisert, eller ikke
  • 23. Sende en melding til systemet
  • 24. Starte eller koble på en Service© 2010 Capgemini. All rights reserved.
  • 25. Intents mellom activites © 2010 Capgemini. All rights reserved. // MovieListActivity.java final Intent intent = new Intent(this, MovieDetails.class); intent.putExtra(MoviesProvider._ID, id); startActivity(intent); // MovieDetailsActivity.java finalIntentintent = getIntent(); long id = intent.getExtras().getLong(MoviesProvider._ID); Insert "Title, Author, Date"
  • 26. Intents mellom applikasjoner © 2010 Capgemini. All rights reserved. // MovieDetailsActivity.java final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(buyTicketLink)); startActivity(intent); // MovieDetailsActivity.java final Intent intent= new Intent(Intent.ACTION_VIEW); intent.setDataAndType( Uri.parse(mMovieDetailsTrailerUrl),"video/*"); startActivity(intent);
  • 27. Byggeklosser i Android © 2010 Capgemini. All rights reserved.
  • 28. Content Provider Wrapper rundt en datakilde For data somønskestilbudttilandreapplikasjoner (egentlig)  Standardiserttilgangtil data vha CONTENT_URI: content://no.jzinema.provider.Movies/movies © 2010 Capgemini. All rights reserved.
  • 29. Content Provider: Persistering © 2010 Capgemini. All rights reserved. Content Provider Sqlite DB // Lagre en film // CONTENT_URI: content://no.jzinema.provider.Movies/movies Uriuri = mContext.getContentResolver(). insert(MoviesProvider.CONTENT_URI, values);
  • 30. Content Provider: Henting av data © 2010 Capgemini. All rights reserved. Content Provider Sqlite DB // MovieDetailsActiviy.java henter en film: //content://no.jzinema.provider.Movies/movies/5 Cursor c = managedQuery(ContentUris.withAppendedId( MoviesProvider.CONTENT_URI, _id), null, null, null, null); // MovieListActivity.java spør // (blant annet) etter alle filmers id Cursor c = managedQuery(MoviesProvider.CONTENT_URI, COLUMN_ID, null, null, null);
  • 31. MoviesContentProvider.java publicclassMoviesProviderextendsContentProvider { publicstaticfinal String AUTHORITY = "no.jzinema.provider.Movies"; publicstaticfinal Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/movies"); @Override publicbooleanonCreate(…) @Override public Uri insert(…) @Override public Cursor query(…) @Override publicint update(…) @Override publicint delete(…) @Override public String getType(…) } Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
  • 32. MovieListActivity: Cursor og CursorAdapter © 2010 Capgemini. All rights reserved. // Alle filmer i en by Cursor cursor = getContentResolver().query( MoviesProvider.CONTENT_URI, COLUMNS, MovieConstants.ATTRIBUTE_ID + " IN (" + movieIds + ")", null, null); startManagingCursor(cursor); // Opprett et cursorAdaptersombenyttercursorentil å populerehverradi listen mAdapter = newMovieListCursorAdapter (this, R.layout.movie_list_row, cursor, COLUMNS, VIEWS_IN_LIST_ROW); // ListActivitytrenger et adapter. this.setListAdapter(mAdapter); Content Provider Sqlite DB
  • 33. DEMO: Live debugging Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
  • 34. Byggeklosser i Android © 2010 Capgemini. All rights reserved.
  • 35. Konfigurering AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="no.capgemini.jzinema” android:versionCode="1” android:versionName="1.0"> <!-- Permissions --> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <!-- Activity for showing a list of movies currently running in the cinemas--> <activity android:name=".MovieList“> <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="no.capgemini.jzinema.SHOW_MOVIELIST" /> </intent-filter> </activity> <providerandroid:authorities="no.jzinema.provider.Movies“ android:name=".provider.MoviesProvider“ /> </application> <uses-sdkandroid:minSdkVersion=“4" /> </manifest> © 2010 Capgemini. All rights reserved.
  • 36. AndroidManifest.xml - utdrag <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="no.capgemini.jzinema” android:versionCode="1” android:versionName="1.0"> <!-- Permissions --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <!-- Activity for showing a list of movies currently running in the cinemas. --> <activity android:name=".activity.movielist.MovieListActivity" android:label="@string/app_name" android:configChanges="orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <providerandroid:authorities="no.jzinema.provider.Movies“ android:name=".provider.MoviesProvider“ /> </application> <uses-sdkandroid:minSdkVersion=“4" /> </manifest> Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
  • 37. Strukturen i en Android-app ligner på en webapp © 2010 Capgemini. All rights reserved.
  • 38. Testing på Android © 2010 Capgemini. All rights reserved.
  • 39. DEMO Robotium Insert "Title, Author, Date" © 2010 Capgemini. All rights reserved.
  • 40. Andre byggeklosser i Android © 2010 Capgemini. All rights reserved.
  • 41. En mobil har sine begrensninger Strøm Datatrafikk Begrenset hardware Cursors, liksom? Komplekse livssykluser Multitasking © 2010 Capgemini. All rights reserved.
  • 42. Aktivitet starter Forenkletlivssyklus for en Activity onCreate() Bruker går tilbake til aktiviteten onStart() onRestart() onResume() Prosess drept Aktivitet kjører Aktivitet havner i forgrunnen Aktivitet havner i bakgrunnen Aktivitet havner i forgrunnen onSaveInstanceState() onPause() Lavt minne Aktiviteten er usynlig onStop() Aktivitet avsluttet Lavt minne, finish() onDestroy() © 2010 Capgemini. All rights reserved.
  • 43.
  • 45. Du veit aldri når’em kommer
  • 46. Nettverk kan være tregt og dyrt
  • 50. Tråder med en handler© 2010 Capgemini. All rights reserved.
  • 52. Fordeler Føles kjent Herlig hardware Debug på device Lett å komme i gang! Godt dokumentert Et moderne OS  GC Ryddige APIer Community Enkelt å publisere © 2010 Capgemini. All rights reserved.
  • 53. Ulemper Mange konfigurasjoner å sikte mot Hardware og OS-versjoner Android Market – ikke Bogstadveien ..og ikke betalte applikasjoner i Norge enda TREG emulator © 2010 Capgemini. All rights reserved.
  • 54. Konklusjon Morsomt Utfordrende begrensninger Vil du utvikle for mobiltelefoner er dette veien å gå! Mer mobilmoro: ”Scala på Androider” kl 14:15, Sal 6 Thor Åge Eldby ”Fra iPhone-idé til AppStore-publisering” Kl 13:30, sal 7 (lyntale) Markuz Lindgren © 2010 Capgemini. All rights reserved.
  • 55. © 2010 Capgemini. All rights reserved. SjekkutJZinema! Last ned frahttp://tinyurl.com/jzinema BETA! (butreleasingon time)
  • 56. Spørsmål? Vi står på Capgeminis stand de neste fire timene Mulighet for å leke med kildekoden på stand eller på http://code.google.com/p/jzinema/ Feeds ikke inkludert! © 2010 Capgemini. All rights reserved.
  • 58. Kilder Pro Android 2 GoogleAndroidphoneshipmentsincrease by 886% - http://www.bbc.co.uk/news/technology-10839034  Google'sAndroidstrategyexplained - http://www.computerworlduk.com/in-depth/mobile-wireless/890/analysis-googles-android-mobile-strategy-explained/  Rich Miner sitert på Internetnews: http://www.internetnews.com/mobility/article.php/12220_3780476_2 Bilder Kløverbilde: cygnus921@flickr Android med Androider: iwallenstein Android-bamse: laihiu@flickr Android YAY – maxbraun@flickr Android Mini Collectibles – droidzebra, Inc Googles første prodserver – jurvetson@flickr Zebra stripes: schnappi@flickr Raptor: XKCD # 135 Record needle: stevecadman@flickr Satellite dish, ryaninc@flickr EvolutionofAndroid: http://www.intomobile.com/2010/07/13/evolution-of-android-follow-the-gingerbread-roadmap/ Andy Rubin ved lanseringen av Android: http://googleblog.blogspot.com/2007/11/wheres-my-gphone.html Ytelse: http://developer.android.com/guide/practices/design/performance.html © 2010 Capgemini. All rights reserved.