Android- From the basics to Guru
-
Upload
joel-r-sosa -
Category
Documents
-
view
192 -
download
1
Transcript of Android- From the basics to Guru
![Page 1: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/1.jpg)
Lesson: From the basics to Android GuruNovember 7, 2015Joel R Sosa
Disclaimer: GDG Puerto Rico is an independent group; our activities and the opinions expressed should in no way be linked to Google, the corporation.
![Page 2: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/2.jpg)
Agenda
Where is Android in the world?
Platform Dissected
Android Studio
Basic AppStructure aka Directories (layout, resources, values)
Types of Resources (strings.xml, colors.xml, styles.xml)
Manifest
More Guru StuffIntents
Adapters
![Page 3: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/3.jpg)
Where is Android in the world?
●1 Billion active devices worldwide!
●1.5 million activated each day!
●22 version codes and counting!
●“Multi platform” reach
●Written in Java
![Page 4: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/4.jpg)
Platform Dissection
KeypadDriver
WIFIDriver
AudioDrivers
PowerManagement
DisplayDriver
CameraDriver
Flash MemoryDriver
Binder (IPC)Driver
LibrariesSurfaceManager
MediaFramewor
kSQLite
OpenGL ES FreeType Webkit
SGL SSL libc
Linux Kernel
Application FrameworkWindow Manager
ContentProviders
ViewSystem
LocationManager
Notification
ManagerPackageManager
TelephonyManager
ResourceManager
ActivityManager
AplicationsHome Browser Phone Contacts ...
CoreLibraries
Android Runtime
![Page 5: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/5.jpg)
Android Studio
● Flexible Gradle-based build system● Build variants and multiple apk file generation● Code templates for common features● Rich layout editor with drag and drop support theme
editing● lint tools to catch performance, version compatibility
and more● ProGuard and app-signing capabilities● Build-in support for Google Cloud Platform
![Page 6: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/6.jpg)
Basic App, demo time!
1. Start a new Android Studio Project2. Configure your new project3. Select the form factors our app will run on (phones, wear, tv, etc)4. Choose a template (Depending your selection here you will add additional info)5. Run it!
Here is what we are going to do!
![Page 7: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/7.jpg)
Demo
![Page 8: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/8.jpg)
Intents
● Represents an abstract description of an operation to be performed.
● Used for lots of things○ Start an Activity○ Broadcast an Intent ○ Start a Service○ Communicate with other apps
● They can be:○ Implicit - an intent that we don’t know which component should be launched.
(example: Launching an url, but with what browser?)○ Explicit - an intent that we define its actions, with a specific component.
(example: Launching Activity B from Activity A within our app)
![Page 9: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/9.jpg)
Example
//An implicit intent.Intent intent = new Intent(Intent.ACTION_SEND);intent.setType("text/plain");intent.putExtra(Intent.EXTRA_TEXT, messageText);String chooserTitle = getString(R.string.chooser);Intent chosenIntent = Intent.createChooser(intent, chooserTitle);startActivity(chosenIntent);
![Page 10: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/10.jpg)
Example
//An implicit intent.Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain");intent.putExtra(Intent.EXTRA_TEXT, messageText);String chooserTitle = getString(R.string.chooser);Intent chosenIntent = Intent.createChooser(intent, chooserTitle);startActivity(chosenIntent);
![Page 11: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/11.jpg)
Example
//An implicit intent.Intent intent = new Intent(Intent.ACTION_SEND);intent.setType("text/plain");intent.putExtra(Intent.EXTRA_TEXT, messageText);String chooserTitle = getString(R.string.chooser);Intent chosenIntent = Intent.createChooser(intent, chooserTitle);startActivity(chosenIntent);
![Page 12: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/12.jpg)
Example
//An implicit intent.Intent intent = new Intent(Intent.ACTION_SEND);intent.setType("text/plain");intent.putExtra(Intent.EXTRA_TEXT, messageText);String chooserTitle = getString(R.string.chooser);Intent chosenIntent = Intent.createChooser(intent, chooserTitle);startActivity(chosenIntent);
![Page 13: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/13.jpg)
Example
//An implicit intent.Intent intent = new Intent(Intent.ACTION_SEND);intent.setType("text/plain");intent.putExtra(Intent.EXTRA_TEXT, messageText);String chooserTitle = getString(R.string.chooser);Intent chosenIntent = Intent.createChooser(intent, chooserTitle);startActivity(chosenIntent);
![Page 14: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/14.jpg)
Example
//An explicit intentIntent intent = new Intent(this, ReceiveIntentActivity.class);intent.putExtra(ReceiveIntentActivity.EXTRA_MESSAGE, messageText);startActivity(intent);
![Page 15: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/15.jpg)
Example
Intent intent = new Intent(this, ReceiveIntentActivity.class);intent.putExtra(ReceiveIntentActivity.EXTRA_MESSAGE, messageText);startActivity(intent);
![Page 16: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/16.jpg)
Example
Intent intent = new Intent(this, ReceiveIntentActivity.class);intent.putExtra(ReceiveIntentActivity.EXTRA_MESSAGE, messageText);startActivity(intent);
![Page 17: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/17.jpg)
Example
Intent intent = new Intent(this, ReceiveIntentActivity.class);intent.putExtra(ReceiveIntentActivity.EXTRA_MESSAGE, messageText);startActivity(intent);
![Page 18: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/18.jpg)
Example
Intent intent = new Intent(this, ReceiveIntentActivity.class);intent.putExtra(ReceiveIntentActivity.EXTRA_MESSAGE, messageText);startActivity(intent);
![Page 19: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/19.jpg)
Demo
![Page 20: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/20.jpg)
Adapters
● Bridge between UI components● Used to deliver content.● Handle Filtering● Adding new objects to source● Deleting from source● Handle different view types
Indirect Subclasses:
ArrayAdapter<T>, BaseAdapter, CursorAdapter, HeaderViewListAdapter, ListAdapter, ResourceCursorAdapter, SimpleAdapter, SimpleCursorAdapter, SpinnerAdapter, ThemedSpinnerAdapter, WrapperListAdapter
![Page 21: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/21.jpg)
Example
//Android versions represented as an String array, you can use also an ArrayList<T> but it will consume more resourcesString[] mVersions = {"Cupcake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow"};
//Our adapter binds the information to our View, in this case our ListView.ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mVersions);
ListView androidVersionsListView = (ListView) findViewById(R.id.versions_list_view);androidVersionsListView.setAdapter(adapter);
![Page 22: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/22.jpg)
Example
//Android versions represented as an String array, you can use also an ArrayList<T> but it will consume more resourcesString[] mVersions = {"Cupcake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow"};
//Our adapter binds the information to our View, in this case our ListView.ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mVersions);
ListView androidVersionsListView = (ListView) findViewById(R.id.versions_list_view);androidVersionsListView.setAdapter(adapter);
![Page 23: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/23.jpg)
Example
//Android versions represented as an String array, you can use also an ArrayList<T> but it will consume more resourcesString[] mVersions = {"Cupcake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow"};
//Our adapter binds the information to our View, in this case our ListView.ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mVersions);
ListView androidVersionsListView = (ListView) findViewById(R.id.versions_list_view);androidVersionsListView.setAdapter(adapter);
![Page 24: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/24.jpg)
Example
//Android versions represented as an String array, you can use also an ArrayList<T> but it will consume more resourcesString[] mVersions = {"Cupcake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow"};
//Our adapter binds the information to our View, in this case our ListView.ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mVersions);
ListView androidVersionsListView = (ListView) findViewById(R.id.versions_list_view);androidVersionsListView.setAdapter(adapter);
![Page 25: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/25.jpg)
Example
//Android versions represented as an String array, you can use also an ArrayList<T> but it will consume more resourcesString[] mVersions = {"Cupcake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow"};
//Our adapter binds the information to our View, in this case our ListView.ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mVersions);
ListView androidVersionsListView = (ListView) findViewById(R.id.versions_list_view);androidVersionsListView.setAdapter(adapter);
![Page 26: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/26.jpg)
Demo
![Page 27: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/27.jpg)
There still lot’s more!(too much to present in 30 mins)
● RecyclerView● CoordinatorLayout● Snackbars● <include>’s● Flavors● Fragments● Gradle Tasks● Unit Testing
● Service● IntentService● BroadcastIntent● Custom Components● Libraries● AsynTasks● Third party API’s ● Many many many… more :)
![Page 28: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/28.jpg)
App examples:
![Page 29: Android- From the basics to Guru](https://reader035.fdocuments.net/reader035/viewer/2022062412/5888921b1a28ab3e658b6ec9/html5/thumbnails/29.jpg)
Time to develop for 1 billion+ usersthe journey to guru just started!
@JRSosa
@JoelRSosa