27
No internet!! Let your apps still work SANGHARSH BOUDHH CO-FOUNDER @ PAPERTOSTONE

No internet!! Let your apps still work

Embed Size (px)

Citation preview

Page 1: No internet!! Let your apps still work

Nointernet!!Letyourappsstillwork

SANGHARSHBOUDHH

CO-FOUNDER@PAPERTOSTONE

Page 2: No internet!! Let your apps still work

– Photosharingb/wfriends

Page 3: No internet!! Let your apps still work

Whatdoesitmean?Connectivity isnotguaranteed

Wehaveallseenmanyappswhichworksseamlesslywithout internet

Source:http://www.techgainer.com/whatsapp-message-sent-delivered-and-read-status-identification/

Andmanymore…

Page 4: No internet!! Let your apps still work

HelloAndroid!!

Source:http://www.wired.com/2011/12/only-android-compatible/

ExperiencewithAndroid

Feelfreetointerrupt

Page 5: No internet!! Let your apps still work

Basics- OverviewEventdrivenprogramming

Activity

Intent&Intentfilters

Manifestfile

Service

Contentproviders

Broadcastreceivers

Layouts

Page 6: No internet!! Let your apps still work

Event-drivenprogrammingStartajavaprogram◦ main function runs

Android◦ Userclickedonbutton◦ Screenstarting◦ GPSLocationchanged◦ Anotherappissharing image

Page 7: No internet!! Let your apps still work

ActivityProvidesascreen

Hooksfor◦ Hey,screenisstarting whatdoyouwanttodo◦ Hey,screenisstoppingwhatdoyouwanttodo◦ Hey,screenisbecomingvisible/invisiblewhatdoyouwanttodo

Source:http://www.edureka.co/blog/android-tutorials-for-beginners-activity-component/

Page 8: No internet!! Let your apps still work

Intent&IntentFiltersIntent◦ Implicit◦ Shareajoke(text)◦ Openmapslink

◦ https://www.google.co.in/maps/place/Kozhikode,+Kerala

◦ Explicit◦ Openanotherscreen(activity)inmyapp

IntentFilter◦ Capabletoshareimages◦ Capabletoopenlinkstomydomain Source:http://slidenerd.com/2014/10/31/android-intents-explicit-and-implicit-intents/

Page 9: No internet!! Let your apps still work

ManifestfileWaytotellrequirement&capabilitiesofyourapp◦ Activities◦ Services,Receivers◦ Permissions◦ Wanttoknowpreciselocationofuser

◦ Feature◦ Deviceshould havecamera

Page 10: No internet!! Let your apps still work

ServiceLongrunningoperation

Inbackground◦ Noscreen

Operationstillneedstorunindifferentthread

Page 11: No internet!! Let your apps still work

ContentProviderCoveredlaterinpresentation

Page 12: No internet!! Let your apps still work

BroadcastReceiversTrigger◦ Letmeknow,whendeviceisputoncharging◦ Letmeknow,whenSMSisreceived

Performsomelogic◦ Startanactivity◦ Senddatatoserver

Page 13: No internet!! Let your apps still work

Layouts

Page 14: No internet!! Let your apps still work

ThreadsOnemainexecutionthread◦ Should notbeblocked◦ UImanipulation canhappenonlyhere

Longrunningoperations◦ Doneondifferent thread

Page 15: No internet!! Let your apps still work

AndroidEssentialsCrashreporting◦ ACRA,Crashlytics,Crittercism

Analytics◦ GoogleAnalytics,Flurry,Mixpanel

JSON(de-)serialization◦ Gson

HTTPlibrary◦ Retrofit,Volley,Loopj

Pushnotifications◦ GCM◦ Parse,CleverTap,Moengage,Qgraph

Imagehandling◦ Picasso

InstallTracking◦ TUNE, AppsFlyer

Page 16: No internet!! Let your apps still work

DataStorageKey-Valuepairs◦ SharedPreferences◦ “organization”:”Cafit”;“conference”:“Reboot”

◦ Singlevalueitemse.g.userpreferences

Files

Relationaldata◦ Outofthebox:SQLite◦ Multiple rowsofdata◦ Normalizeddataform

Page 17: No internet!! Let your apps still work

ConnectingtoyourserverBasics◦ AsyncTask◦ HttpURLConnection

Libraries◦ Retrofit bySquare◦ Volley◦ Loopj

Page 18: No internet!! Let your apps still work

SyncFrameworkProvides◦ Robustframeworkoutofthebox◦ Automatednetworkchecking◦ Improvedbatteryperformance◦ Scheduling, Retries

Implementation◦ Authenticator◦ ContentProvider◦ SyncAdapter

Resource◦ TransferringDataUsingSyncAdapters◦ Howtodevelopanoffline-firstnativeAndroid app

Page 19: No internet!! Let your apps still work

AuthenticatorRegistersuserinAndroidSystem(Settings>Accounts)

Stubitorimplementit◦ Dependsonlogin requirementofyourserver-side

ExtendsAbstractAccountAuthenticator

Register◦ Metadatafile

Source:◦ AbstractAccountAuthenticator◦ Stub Authenticator

Page 20: No internet!! Let your apps still work

BonusAppsshowsupinSettings>Accounts

Page 21: No internet!! Let your apps still work

ContentProviderWhat◦ Sharingdatawithotherapps◦ Accessingdataofotherapps◦ E.g.Contacts,Calendar

◦ Morestructuredwaytoaccessowndata

Resources◦ ContentProvider◦ Stubprovider◦ Simpleprovider – Greatlibrarytostart

Advancedcases◦ Joining tables◦ Visibilityhandling

Page 22: No internet!! Let your apps still work

SyncAdapterExtendAbstractThreadedSyncAdapter

Page 23: No internet!! Let your apps still work

Boundservice

Page 24: No internet!! Let your apps still work

SyncAdapter- RegisterMetadatafile

AndroidManifest

Page 25: No internet!! Let your apps still work

SyncAdapter–WhentorunWhenserverdatachanges◦ GCM

◦ ContentResolver.requestSync()

Whendevicedatachanges◦ ContentProviderdetectschange

◦ ContentObserver.onChange()

Periodically◦ Atregularintervals◦ Specifictimesofday

◦ ContentResolver.addPeriodicSync()

Ondemand◦ Inresponsetouser’saction

◦ ContentResolver.requestSync()

Page 26: No internet!! Let your apps still work

AdditionalbenefitsLoaders◦ Asynchronous loadingofdata◦ Autorefreshoncontentchange◦ Plugs inwellwithContentProvider andCursors◦ https://developer.android.com/guide/components/loaders.html

Sharingdataacrossapps

Systemchecksconnectivityforyou

Page 27: No internet!! Let your apps still work

ThankyouJWouldlovetochataboutAndroid,Node.js,Angular.js,Elasticsearch,Startupsoranythingafterthetalk

- SangharshBoudhh

[email protected]

www.papertostone.com

https://www.linkedin.com/in/sangharshboudhh