+ All Categories
Home > Mobile > Android for Beginners

Android for Beginners

Date post: 26-Jan-2017
Category:
Upload: ganesh-kanna-s
View: 72 times
Download: 1 times
Share this document with a friend
41
Workshop on Android Programming
Transcript
Page 1: Android  for Beginners

Workshop on Android Programming

Page 2: Android  for Beginners

Why Android?

Page 3: Android  for Beginners

Distribution - Chart

Page 4: Android  for Beginners

API Level

Page 5: Android  for Beginners

Android Architecture

Page 6: Android  for Beginners

Android Components

• ActivityUI component typically corresponds to one screen

• Intent ReceiverReceives events from phone

• ServiceFaceless task that runs in the background

• Content ProviderStores data and makes it available to other applications

Page 7: Android  for Beginners

Activity Life Cycle

Page 8: Android  for Beginners

Back Stack

Page 9: Android  for Beginners

App Resources

Same Resource

Page 10: Android  for Beginners

App Resources

Multiple Resource

Page 11: Android  for Beginners

App Resources

Providing Resources

Page 12: Android  for Beginners

App Resources

Accessing Resources

Page 13: Android  for Beginners

App Resources

Localization• res/values/strings.xml

Contains English text for all the strings that the application uses, including text for a string named title.

• res/values-fr/strings.xmlContain French text for all the strings, including title.

• res/values-ja/strings.xmlContain Japanese text for all the strings except title.

Page 14: Android  for Beginners

App Resources

Resources Types• Animation Resources

Define pre-determined animations.Tween animations are saved in res/anim/ and accessed from the R.anim class.Frame animations are saved in res/drawable/ and accessed from the R.drawable class.

• Color State List ResourceDefine a color resources that changes based on the View state.Saved in res/color/ and accessed from the R.color class.

Page 15: Android  for Beginners

App Resources

Resources Types• Drawable Resources

Define various graphics with bitmaps or XML.Saved in res/drawable/ and accessed from the R.drawable class.

• Layout ResourceDefine the layout for your application UI.Saved in res/layout/ and accessed from the R.layout class.

• Menu ResourceDefine the contents of your application menus.Saved in res/menu/ and accessed from the R.menu class.

Page 16: Android  for Beginners

App Resources

Resource Types• String Resources

Define strings, string arrays, and plurals (and include string formatting and styling).Saved in res/values/ and accessed from the R.string, R.array, and R.plurals classes.

• Style ResourceDefine the look and format for UI elements.Saved in res/values/ and accessed from the R.style class.

Page 17: Android  for Beginners

User Interface

Layouts – Linear Layout

VerticalHorizontal

Page 18: Android  for Beginners

User Interface

Layouts – Relative Layout

Page 19: Android  for Beginners

User Interface

Layouts – List View/ Grid View

Displays a scrolling single column list.

Displays a scrolling grid of columns and rows

Page 20: Android  for Beginners

User Interface

Input Controls

Page 21: Android  for Beginners

User Interface

Input Controls – Spinner

Page 22: Android  for Beginners

User Interface

Input Controls – Picker

Page 23: Android  for Beginners

Supporting Multiple Screens

Screen sizeScreen densityOrientationResolutionDevice Independent Pixel

px = dp * (dpi / 160)

Page 24: Android  for Beginners

Supporting Multiple Screen

◦ ldpi (low) ~120dpi◦ mdpi (medium) ~160dpi◦ hdpi (high) ~240dpi◦ xhdpi (extra-high) ~320dpi◦ xxhdpi (extra-extra-high) ~480dpi◦ xxxhdpi (extra-extra-extra-high) ~640dpi

Page 25: Android  for Beginners

Supporting Multiple Screen

Page 26: Android  for Beginners

Supporting Multiple Screen

Page 27: Android  for Beginners

Supporting Multiple Screen

• 36x36 (0.75x) for low-density• 48x48 (1.0x baseline) for medium-density• 72x72 (1.5x) for high-density• 96x96 (2.0x) for extra-high-density• 144x144 (3.0x) for extra-extra-high-density• 192x192 (4.0x) for extra-extra-extra-high-density

Page 28: Android  for Beginners

Code Snippets

Page 29: Android  for Beginners

Views

• TextView• Button• ToggleButton• CheckBox• RadioButton• Spinner• SeekBar• Switch

Page 30: Android  for Beginners

Views

• TextFields• Layouts• Containers• Images• AppCompat

Page 31: Android  for Beginners

Events• onClick()• onLongClick()• onFocusChange()• onKey()• onTouch()• onCreateContextMenu()

Page 32: Android  for Beginners

Utilities to Know

Call to PhoneIntent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:"+number)); startActivity(callIntent); <uses-permission android:name="android.permission.CALL_PHONE" />

Page 33: Android  for Beginners

Utilities to Know

Open URL in browser

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));startActivity(browserIntent);

Page 34: Android  for Beginners

Utilities to Know

Open E-mail App

Intent i = new Intent(Intent.ACTION_SEND);i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ emailAddress });i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);i.putExtra(android.content.Intent.EXTRA_TEXT, text);startActivity(Intent.createChooser(i, "Send email"));

Page 35: Android  for Beginners

Data Storage

Shared PreferencesStore private primitive data in key-value

pairs.Internal Storage

Store private data on the device memory.External Storage

Store public data on the shared external storage.SQLite Databases

Store structured data in a private database.Network Connection

Store data on the web with your own network server.

Page 36: Android  for Beginners

Data Storage

Shared Preferences

// Restore preferencesSharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);boolean silent = settings.getBoolean("silentMode", false);

SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);SharedPreferences.Editor editor = settings.edit();editor.putBoolean("silentMode", mSilentMode);// Commit the edits!editor.commit();

Page 37: Android  for Beginners

Fragments• A fragment has its own layout and its own behavior with its

own life cycle callbacks.• You can add or remove fragments in an activity while the

activity is running.• You can combine multiple fragments in a single activity to

build a multi-plane UI.• A fragment can be used in multiple activities.

Page 38: Android  for Beginners

Android Challanges

• Software Fragmentation• Hardware Fragmentation• No Software/Hardware Standardization• Several Carriers• Security

Page 40: Android  for Beginners

Questions?

Page 41: Android  for Beginners

THANK YOU!


Recommended