Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Offlinefähige Apps für Android entwickeln (Karlsruher Entwicklertag 2014)

512 views

Published on

Trotz des immer schnelleren mobilen Internets gibt es Situationen, in denen man auf dem Smartphone keine Datenverbindung hat. Dennoch möchte man, z.B. während einer Zugfahrt, neue RSS-Feeds oder Nachrichten auf Twitter lesen. Die Apps dafür müssen also offlinefähig sein und ihre Daten lokal vorhalten.

Diese Session zeigt, wie man eine App für Android entwickeln kann, die Daten mit einem Service synchronisiert, sodass die App auch ohne aktive Datenverbindung benutzt werden kann.

Zuerst wird hierzu der passende Architekturansatz vorgestellt. Danach werden Schritt für Schritt die benötigten Android APIs anhand von kleinen Demos vorgestellt, bis schließlich daraus die fertige App entsteht.

Published in: Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Offlinefähige Apps für Android entwickeln (Karlsruher Entwicklertag 2014)

  1. 1. Überleben im FunklochOfflinefähige Apps für Android entwickeln ChristianJanz( )@c_janz christian.janz@bridging-it.de
  2. 2. Twitter: | E-Mail: Slides: Christian Janz Consultantim Bereich SoftwareentwicklungJava/JEE bei in MannheimBridging IT Interesse: Architektur und Entwicklungvon Geschäftsanwendungen mitHilfe moderner JavaFrameworks @c_janz christian.janz@bridging-it.de http://de.slideshare.net/cjanz
  3. 3. Agenda Motivation Lösungsidee Architekturansatz APIs im Einsatz: Sync Sample Fazit
  4. 4. Motivation
  5. 5. 1. Juli2013
  6. 6. Lösungsidee
  7. 7. Synchronisiere Daten und speichere sie lokal auf dem Gerät
  8. 8. Vorteile App kann auch ohne aktive Datenverbindunggenutztwerden Datenvolumen wird reduziert Akkulaufzeitwird erhöht Daten werden automatisch aktualisiert, wenn eine Datenverbindungbesteht Retrybeiabgebrochener Verbindung "Nebenbei": Verbesserte Architektur
  9. 9. Architektur
  10. 10. "DevelopingAndroidREST Client Applications" Architekturansatz für Android Vortragvon VirgilDobjanschiauf der Google IO 2010
  11. 11. Quelle: Developing Android RESTClient Applications
  12. 12. SyncAdapter: Features Beachten von Netzwerkverfügbarkeit Synchronisation auch wenn App nichtläuft Periodische Synchronisation Warteschlage Bündeln von Syncs: Gutfür Akkulaufzeit Integration in globale Sync-Einstellungen Integration in Account-Verwaltung
  13. 13. APIs im Einsatz: Sync Sample
  14. 14. Vorgehen Authenticator &Account ContentProvider RESTclient SyncAdapter UI
  15. 15. https://github.com/cjanz/android-sync-sample
  16. 16. Authenticator & Account AuthenticatorService Authenticator LoginActivity authenticator.xml AndroidManifest.xml
  17. 17. authenticator.xml <account-authenticator xmlns:android="http://schemas.android.com/apk/res/android" android:accountType="de.bit.android.sample.account" android:icon="@drawable/ic_launcher" android:smallIcon="@drawable/ic_launcher" android:label="@string/app_name" />
  18. 18. AndroidManifest.xml <service android:name="de.bit.android.syncsample.authenticator.AuthenticatorService"> <intent-filter> <actionandroid:name="android.accounts.AccountAuthenticator"/> </intent-filter> <meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"/> </service> <activity android:name="de.bit.android.syncsample.authenticator.LoginActivity" android:excludeFromRecents="true" android:exported="true" android:theme="@android:style/Theme.Holo"> </activity>
  19. 19. Demo: Authenticator & Account
  20. 20. ContentProvider TodoContentProvider DatabaseHelper TodoEntity AndroidManifest.xml
  21. 21. TodoEntity publicclassTodoEntity{ privateLongid; privateLongserverId; privateLongserverVersion; privateLongconflictedServerVersion; privateSyncStatesyncState=SyncState.NOOP; privateStringtitle; privateStringtext; ...(gettersandsetters) }
  22. 22. REST client publicclassTodoRestClient{ publicstaticList<TodoEntity>loadAllTodos()throwsIOException,JSONException; publicstaticTodoEntitysaveTodo(TodoEntitytodoEntity)throwsIOException,JSONExceptio publicstaticvoiddeleteTodo(TodoEntitytodoEntity)throwsIOException; }
  23. 23. SyncAdapter SyncService SyncAdapter syncadapter.xml AndroidManifest.xml
  24. 24. syncadapter.xml <?xmlversion="1.0"encoding="utf-8"?> <sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" android:accountType="de.bit.android.sample.account" android:contentAuthority="de.bit.android.syncsample.content" android:supportsUploading="true"/>
  25. 25. AndroidManifest.xml <serviceandroid:name="de.bit.android.syncsample.sync.SyncService"> <intent-filter> <actionandroid:name="android.content.SyncAdapter"/> </intent-filter> <meta-data android:name="android.content.SyncAdapter" android:resource="@xml/syncadapter"/> </service>
  26. 26. Demo: Speichern der Daten vom Backend @Override publicvoidonPerformSync(Accountaccount,Bundleextras,Stringauthority, ContentProviderClientprovider,SyncResultsyncResult){ ... }
  27. 27. Periodische Synchronisation privatevoidconfigureSync(Accountaccount){ ContentResolver.setIsSyncable(account,CONTENT_AUTHORITY,1); ContentResolver.setSyncAutomatically(account,CONTENT_AUTHORITY,true); Bundleparams=newBundle(); params.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED,false); params.putBoolean(ContentResolver.SYNC_EXTRAS_DO_NOT_RETRY,false); params.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL,false); ContentResolver.addPeriodicSync(account,CONTENT_AUTHORITY,params,60); ContentResolver.requestSync(account,CONTENT_AUTHORITY,params); }
  28. 28. UI MainActivity activity_main.xml todo_row.xml EditTodoActivity activity_edit_todo.xml AndroidManifest.xml
  29. 29. Demo: Sync-Status anzeigen @Override protectedvoidonResume(){ super.onResume(); syncObserverHandle=ContentResolver.addStatusChangeListener( SYNC_OBSERVER_TYPE_ACTIVE|SYNC_OBSERVER_TYPE_PENDING,this); } @Override publicvoidonStatusChanged(intwhich){ runOnUiThread(newRunnable(){ @Override publicvoidrun(){ booleanisSyncActive=ContentResolver.isSyncActive(account, TodoContentProvider.AUTHORITY); setProgressBarIndeterminateVisibility(isSyncActive); } }); }
  30. 30. Demo: Synchronisation anstoßen Bundleparams=newBundle(); params.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED,true); params.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL,true); ContentResolver.requestSync(account,TodoContentProvider.AUTHORITY, params);
  31. 31. Demo: Automatisches Update der UI CursorLoader und ContentResolver.notifyChange(...)
  32. 32. Demo: Create, Update, Delete
  33. 33. Fazit
  34. 34. Offlinefähige Apps haben Vorteile Offlinefähigkeitmuss nichtaufwändigsein Android bietetgute Unterstützungdafür Dokumentation nichtoptimal Fehlerhandlingmuss beachtetwerden
  35. 35. Links Transferring Data Using SyncAdapters | Android Developers Slides: Android SyncAdapter | AlexTumanoff Tutorial: Writeyour ownAndroid SyncAdapter | Udinic SyncAdapter SampleApp| ChristianJanz
  36. 36. Fragen?
  37. 37. meet the SPEAKER @speakerlounge 1. OG DIREKT ÜBER DEM EMPFANG

×