Welcome !
Android Motivation
Senthil ACS
senthil.acs@gmail.com
Why Motivation?
Motivation drives your growth
Specifically “Self Motivation”
Beneficiaries – You and your organization
Today’s Motivation – Android
What is Android?
It is not an Operating System….
An open source software stack build on top of Linux
Language – Java
Provides an infrastructure for advanced applications.
Helps developers use that infrastructure for apps
Android Development
Third party app development
Our agenda
Ability to monetize apps
http://developer.android.com
Native Platform development
Mobile Phone makers (HTC, Samsung, Motorola)
Genuine geeks
Cannot monetize
http://source.android.com
Android SDK
Started – Cupcake (1.5)
Current – Jelly Bean(4.1)
Your requirements
Windows/Linux/Mac
Eclipse Helios onwards (http://www.eclipse.org)
Eclipse Android Development Plugin (ADT)
Android SDK (Android JARS + Emulators)
Question – Difference between Simulator and
Emulator???
Simulator and Emulator
Simulator
A system designed only to test your software
Flight Simulator
Space Simulator
Obviously you cannot fly 
Emulator
Test your target architecture on another computer
Copy the real hardware and software into another
computer
Android Emulator
What will you learn today?
SDK Setup
Hello World Application
Adding more concepts to the application
Practical correlation of Android concepts
Writing a Location based application
Device Management
Agenda
Hello World Application
Application Components
Concepts
 Activity
 Service
 App Storage
 Broadcast Receivers
 Android Permissions
 Location and Maps
 Debugging
Device Management
Hello World App
Create a new project in Eclipse using Android SDK
You are done !!!
Lets try!!!
App Components
Source
Resources
Drawables (various screen sizes)
Layout (various screen sizes)
Strings (various languages)
Manifest
Contains all activities, services, providers, receivers,
permissions required by the application
Application Needs
UI (Activity)
Background Worker (Service)
App Storage (Shared Prefs, Internal/External Storage,
Content Providers)
Change receivers (Broadcast Receiver)
Android Activity
Anything that the application does
A UI window containing various
views (Button, TextView, Label etc) –
Similar to Java Swings
View elements may listen for user
actions
An application can have various
activities
One can start another (Opening one
window from another window) –
Using startActivity(intent)
Launcher Activity
The activity that shows up when the app is launched
Manifest changes
<activity android:name=".ExampleActivity"
android:icon="@drawable/app_icon">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Activity Lifecycle
Activity Lifecycle
Lets try it out!!!
Create an app
Check the Manifest for Launcher Activity
Create a Sub Activity and launch it from the main activity
Return the sub activity result to the main activity
Add some UI elements
Activity Lifecycle example – Google provided
Services
To run in background & no UI
Types - Started Services, Bound Services
Started Services
Owned by the application
Typically started by an activity
Bound Services
Owned by the application
Shared by others – Binder
Invoking a Service
startService()
Code to start a service
Intent intent = new Intent(this, HelloService.class);
startService(intent);
onStartCommand()
bindService()
onBind()
Requires an Intent action/Service class name
Started Service
Intent Service
Offloads to a Worker Thread
Provides a Work Queue
Stops the service once work is done
Less code
Normal Service
Manually create background thread
Multi threaded work
More code
Service Lifecycle
Lets try it out!!!
Create three Services
Intent Service – One at a time
Normal Service – One at a time
Normal Service – Multi Request
Bound Service (If time permits)
Use an Activity to launch the service
Update Manifest with the service declarations
Application Storage
Shared Preferences
User’s settings
Key-Value Pairs
Internal Storage
App’s private data
Cannot be accessed by other apps
External Storage
Public data
Typically sdcard
Content Providers
Content Providers
Identified using a URI
SQLite databases
Efficient data access
Can be accessed by other apps
Example: Read Contacts
Content Providers
CRUD
Create
Read
Update
Delete
API: SQLiteOpenHelper
Read and Write database
Contains CRUD methods
Lets try it out !!!
Create a content provider step by step
SQLiteOpenHelper instance
SQLiteDatabase instance
Implement CRUD methods
Store student name and percentage
Show the saved data
Listeners & Broadcast Receivers
Hey Friend! Inform us when the results are out!!
Above statement – Registration
You – Listener
Your Friend – Broadcaster
“When the results are out” – Intent
Listeners & Broadcast Receivers
Register for event notifications
Signal Change Notification
On boot complete Notification
Battery Notification
Location Change Notification
Etc…
Communicate results from one app to other/others
Listeners & Broadcast Receivers
Registration
Permanent
Register in Manifest
Example: onBootComplete
On/Off
Register/Unregister when required
Example: Location Change Notification
Lets try it out !!!
Create an application that will show Signal changes
Let the application be launched on Boot
Register/UnRegister signal changes
Intent & Intent Filter
Intent – The intention behind doing something
Used in Services example to pass data.
Intent Filter – What are my intentions?
Used in Broadcast receivers to specify what to listen to.
Android Permissions
Declared in Manifest
Required if your app uses Android sensitive infrastructure
Read/Write contacts
Read Network State
Read/Write External Storage (App Storage)
OnBootComplete
Etc…
More Concepts
More UI Concepts
 Alert Dialogs
 Date, Time dialogs
 ANR
 Pick Contacts
 Notification/Toasts
Location, Maps Activity
 Usage of Broadcast Receivers
 Use Google APIs in Android
Device Management
 Need for Securing Mobile Devices
UI Concepts
Dialogs
Alerts the user for info or some input
ANR – Application Not Responding
Drives the developer crazy
Never run long running tasks in UI Thread
Remember – LoaderCallbacks<CursorLoader>?
Lets try out a sample showing all the above PLUS
How to launch Contacts app
Location and Maps
Google APIs (MapActivity)
Obtain Maps API Key
Require Internet Permission
Maps add Overlay Items
Location Information – GPS/Network
Lets try it out!!!
Write a MapActivity
Register for Location from GPS/Network
Place that location onto the Map as a OverlayItem
Point using a Marker – A Pin
Permission Requirements for the App
Device Management
Set Password Policy
Encrypt storage
Remote Lock/Wipe
Control Camera
What is the need?
Lost your device?
Remotely Lock your device
Install Apps such as Lookout
Try to get the location after losing
Configure alternate numbers in Lookout
Get SMS when the SIM card is changed
More chances of getting the device back
We are done!!!
Benefits of learning Android
Massive market share (50 to 60%) of global smartphone
share.
Samsung, Motorola, Sony, LG, HTC are major players
Play Store – 500000+ apps
Get a fundoo job
Monetize your application
JOB !!!
Show your marks and answer simple Questions
Learn Android + One app in PlayStore
Data Structures + Algorithms + 1 Mobile Platform
JOB !!!
Show your marks and answer simple Questions – Service
Companies - Infosys, Wipro, HCL, CTS, TCS etc…
Android – Good Product Companies – Zomato, Zynga,
SAP, Ericsson
Data Structures + Algorithms + 1 Mobile Platform –
Premium Product Companies
Google, Yahoo, Microsoft, Akamai
JOB !!!
Service Companies – 2.5 to 3.5
Product Companies – 4.0 to 5.5
Premium Product Companies – 7 to 12
What Now !!!
Pick up Android SDK and use the developer link to kick
start
Develop small apps and relish 
Find an idea, develop it and put it in playstore.
25$ to put in PlayStore
I have an account – You can use it free
Get back to me with your questions
Android Help??
Project Help??
Android References
http://developer.android.com
Questions ?
http://www.stackoverflow.com
Senthil.acs@gmail.com

Android_ver_01

  • 1.
  • 2.
  • 3.
    Why Motivation? Motivation drivesyour growth Specifically “Self Motivation” Beneficiaries – You and your organization Today’s Motivation – Android
  • 4.
    What is Android? Itis not an Operating System…. An open source software stack build on top of Linux Language – Java Provides an infrastructure for advanced applications. Helps developers use that infrastructure for apps
  • 5.
    Android Development Third partyapp development Our agenda Ability to monetize apps http://developer.android.com Native Platform development Mobile Phone makers (HTC, Samsung, Motorola) Genuine geeks Cannot monetize http://source.android.com
  • 6.
    Android SDK Started –Cupcake (1.5) Current – Jelly Bean(4.1) Your requirements Windows/Linux/Mac Eclipse Helios onwards (http://www.eclipse.org) Eclipse Android Development Plugin (ADT) Android SDK (Android JARS + Emulators) Question – Difference between Simulator and Emulator???
  • 7.
    Simulator and Emulator Simulator Asystem designed only to test your software Flight Simulator Space Simulator Obviously you cannot fly  Emulator Test your target architecture on another computer Copy the real hardware and software into another computer Android Emulator
  • 8.
    What will youlearn today? SDK Setup Hello World Application Adding more concepts to the application Practical correlation of Android concepts Writing a Location based application Device Management
  • 9.
    Agenda Hello World Application ApplicationComponents Concepts  Activity  Service  App Storage  Broadcast Receivers  Android Permissions  Location and Maps  Debugging Device Management
  • 10.
    Hello World App Createa new project in Eclipse using Android SDK You are done !!!
  • 11.
  • 12.
    App Components Source Resources Drawables (variousscreen sizes) Layout (various screen sizes) Strings (various languages) Manifest Contains all activities, services, providers, receivers, permissions required by the application
  • 13.
    Application Needs UI (Activity) BackgroundWorker (Service) App Storage (Shared Prefs, Internal/External Storage, Content Providers) Change receivers (Broadcast Receiver)
  • 14.
    Android Activity Anything thatthe application does A UI window containing various views (Button, TextView, Label etc) – Similar to Java Swings View elements may listen for user actions An application can have various activities One can start another (Opening one window from another window) – Using startActivity(intent)
  • 15.
    Launcher Activity The activitythat shows up when the app is launched Manifest changes <activity android:name=".ExampleActivity" android:icon="@drawable/app_icon"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
  • 16.
  • 17.
  • 18.
    Lets try itout!!! Create an app Check the Manifest for Launcher Activity Create a Sub Activity and launch it from the main activity Return the sub activity result to the main activity Add some UI elements Activity Lifecycle example – Google provided
  • 19.
    Services To run inbackground & no UI Types - Started Services, Bound Services Started Services Owned by the application Typically started by an activity Bound Services Owned by the application Shared by others – Binder
  • 20.
    Invoking a Service startService() Codeto start a service Intent intent = new Intent(this, HelloService.class); startService(intent); onStartCommand() bindService() onBind() Requires an Intent action/Service class name
  • 21.
    Started Service Intent Service Offloadsto a Worker Thread Provides a Work Queue Stops the service once work is done Less code Normal Service Manually create background thread Multi threaded work More code
  • 22.
  • 23.
    Lets try itout!!! Create three Services Intent Service – One at a time Normal Service – One at a time Normal Service – Multi Request Bound Service (If time permits) Use an Activity to launch the service Update Manifest with the service declarations
  • 24.
    Application Storage Shared Preferences User’ssettings Key-Value Pairs Internal Storage App’s private data Cannot be accessed by other apps External Storage Public data Typically sdcard
  • 25.
    Content Providers Content Providers Identifiedusing a URI SQLite databases Efficient data access Can be accessed by other apps Example: Read Contacts
  • 26.
  • 27.
    Lets try itout !!! Create a content provider step by step SQLiteOpenHelper instance SQLiteDatabase instance Implement CRUD methods Store student name and percentage Show the saved data
  • 28.
    Listeners & BroadcastReceivers Hey Friend! Inform us when the results are out!! Above statement – Registration You – Listener Your Friend – Broadcaster “When the results are out” – Intent
  • 29.
    Listeners & BroadcastReceivers Register for event notifications Signal Change Notification On boot complete Notification Battery Notification Location Change Notification Etc… Communicate results from one app to other/others
  • 30.
    Listeners & BroadcastReceivers Registration Permanent Register in Manifest Example: onBootComplete On/Off Register/Unregister when required Example: Location Change Notification
  • 31.
    Lets try itout !!! Create an application that will show Signal changes Let the application be launched on Boot Register/UnRegister signal changes
  • 32.
    Intent & IntentFilter Intent – The intention behind doing something Used in Services example to pass data. Intent Filter – What are my intentions? Used in Broadcast receivers to specify what to listen to.
  • 33.
    Android Permissions Declared inManifest Required if your app uses Android sensitive infrastructure Read/Write contacts Read Network State Read/Write External Storage (App Storage) OnBootComplete Etc…
  • 34.
    More Concepts More UIConcepts  Alert Dialogs  Date, Time dialogs  ANR  Pick Contacts  Notification/Toasts Location, Maps Activity  Usage of Broadcast Receivers  Use Google APIs in Android Device Management  Need for Securing Mobile Devices
  • 35.
    UI Concepts Dialogs Alerts theuser for info or some input ANR – Application Not Responding Drives the developer crazy Never run long running tasks in UI Thread Remember – LoaderCallbacks<CursorLoader>? Lets try out a sample showing all the above PLUS How to launch Contacts app
  • 36.
    Location and Maps GoogleAPIs (MapActivity) Obtain Maps API Key Require Internet Permission Maps add Overlay Items Location Information – GPS/Network
  • 37.
    Lets try itout!!! Write a MapActivity Register for Location from GPS/Network Place that location onto the Map as a OverlayItem Point using a Marker – A Pin Permission Requirements for the App
  • 38.
    Device Management Set PasswordPolicy Encrypt storage Remote Lock/Wipe Control Camera What is the need?
  • 39.
    Lost your device? RemotelyLock your device Install Apps such as Lookout Try to get the location after losing Configure alternate numbers in Lookout Get SMS when the SIM card is changed More chances of getting the device back
  • 40.
  • 41.
    Benefits of learningAndroid Massive market share (50 to 60%) of global smartphone share. Samsung, Motorola, Sony, LG, HTC are major players Play Store – 500000+ apps Get a fundoo job Monetize your application
  • 42.
    JOB !!! Show yourmarks and answer simple Questions Learn Android + One app in PlayStore Data Structures + Algorithms + 1 Mobile Platform
  • 43.
    JOB !!! Show yourmarks and answer simple Questions – Service Companies - Infosys, Wipro, HCL, CTS, TCS etc… Android – Good Product Companies – Zomato, Zynga, SAP, Ericsson Data Structures + Algorithms + 1 Mobile Platform – Premium Product Companies Google, Yahoo, Microsoft, Akamai
  • 44.
    JOB !!! Service Companies– 2.5 to 3.5 Product Companies – 4.0 to 5.5 Premium Product Companies – 7 to 12
  • 45.
    What Now !!! Pickup Android SDK and use the developer link to kick start Develop small apps and relish  Find an idea, develop it and put it in playstore. 25$ to put in PlayStore I have an account – You can use it free Get back to me with your questions Android Help?? Project Help??
  • 46.