welcome to android android development community to android - 22-06-2015… · android development...

29
Welcome to Android Android Development Community “Be together. Not the same.”

Upload: others

Post on 27-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Welcome to Android

Android Development Community

“Be together. Not the same.”

Page 2: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Agenda

● What and Who is Android● Android Architecture● Android Studio● Activity and Fragment● Shared Preferences● Resources

Android Development Community

Page 3: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Android

Page 4: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

● It’s an Open Source Mobile OS

● Owns 80% of the Mobile Market

● It’s one of the main Google products

● It’s open and extensible

● It’s composed by four layers - Linux Kernel, Libraries and Runtime, Application Framework, Applications

● Supports Phones, Tablets, Watches, TV, Auto, Glasses

● Written in C++ and Java

● Android Application Engineers Salaries

What it is? Who is it?

Page 6: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Currently

Owns 78% of theWorldwide

Smartphone OSMarket Share

With billions of devices

Source: http://www.idc.com/prodserv/smartphone-os-market-share.jsp

Page 7: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Android Architecture

Page 8: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Applications is the layer were system and developer apps run.

Application Framework it’s written in Java and it’s a collection of Java APIs that all Android Applications use.

C/C++ Libraries used on top of the Linux Kernel responsible for stable performance of various components

Android Runtime is Dalvik Virtual Machine where our applications are executed.

Linux Kernel for core system services such as security, memory management, process management, network stack and hardware drivers

AndroidArchitecture

Page 9: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Android Studio

Page 10: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

● It’s the Official Android IDE

● Developed and released by Google

● Based on IntelliJ IDEA

● Download IDE

● Uses Gradle by default for building projects

● It’s free of change

Let’s have a look!

Android Studio

Page 11: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application
Page 12: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Activity

Page 13: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

● It’s the base class for every Android application component that contains graphical user interface.

● The latest and recommended base Activity class is AppCompatActivity

● Contains views and/or fragments

● Must be declared in AndroidManifest.xml before trying to use it.

● Should be protected by permissions if doesn’t need to be exposed to the world

● Can be initialized by Intent

● Important methods include onCreate(), onResume(), onActivityResult() and onDestroy()

Activity

Page 14: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Start an ActivityIntent intent = new Intent(HomeActivity.this, DetailActivity.class);

intent.putExtra(SHARED_VIEW, url);

startActivity(intent);

Start an Activity for resultIntent intent = new Intent(HomeActivity.this, DetailActivity.class);

intent.putExtra(SHARED_VIEW, url);

startActivityForResult(intent);

Activity

Page 15: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Activity Lifecycle

Page 16: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Get arguments and save them as needed Set activity layout and inflate views Instantiate Adapters Execute a Loader Retrieve data from Database Register an observer}

void onActivityResult(int requestCode, int resultCode, Intent data){ super.onActivityResult(requestCode, resultCode, data);}

void onResume(){ super.onResume(); Update data in layout if needed Send screen name to Google Analytics}

void onStop(){ super.onStop(); Hide any layout that should be hidden}

void onDestroy(){ super.onDestroy(); Unregister any observer Set to null instance members}

Let’s see usage in source code https://github.com/proverbface/MaterialDesign/

Page 17: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Fragment

Page 18: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

● It’s a piece of reusable user interface

● Can only be used within a host Activity

● Prefered base Fragment class is android.support.v4.app.Fragment

● It’s lifecycle methods are synced with its hosting Activity

● It doesn’t need to be declared in AndroidManifest.xml

● Most important methods include onAttach, onCreate, onCreateView, onResume, onActivityResult, onStop, onDestroy

Fragment

Page 19: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Commit a new FragmentFragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

transaction.setCustomAnimations(R.anim.fadein, R.anim.fadeout, R.anim.fadein, R.anim.fadeout);transaction.replace(R.id.view_container, fragment, fragmentTag);

transaction.addToBackStack(fragmentTag);

transaction.commit();

Pop back to FragmentgetSupportFragmentManager().popBackStack(fragmentTag, FragmentManager.POP_BACK_STACK_INCLUSIVE);

Remove a FragmentgetSupportFragmentManager().beginTransaction().remove(this).commit();

Fragment

Page 20: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Fragment Lifecycle

Page 21: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

void onAttach(Activity activity){ super.onAttach(activity); Save a reference to this activity. Check any required interface.}

void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Get Fragment arguments and save them as needed Instantiate Adapters Execute a Loader Retrieve data from Database Register an observer}

View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ super.onCreateView( inflater, container, savedInstanceState ); return inflater.inflate( getLayoutResId(), container, false );

Inflate layout and get view instances Set values to field views }

Fragment is visible on onCreateView, onActivityCreated, onStart and onResume.

Fragment is not visible on onAttach, onCreate, onPause, onStop, onDestroyView, onDestroy and onDetach

void onResume(){ super.onResume(); Update data in layout if needed Send screen name to Google Analytics}

void onStop(){ super.onStop(); Hide any layout that should be hidden}

void onDestroy(){ super.onDestroy(); Unregister any observer Set to null instance members}

Let’s see usage in source code https://github.com/proverbface/MaterialDesign/

Page 22: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Shared Preferences

Page 23: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

● It’s one of the prefered ways to save application state

● You can have multiple shared preferences files

● Allows easy management of key-value pairs

● The name of the shared preferences is reflected on its xml file name

● Shared Preferences are saved and retrieved from a xml file

● It has 6 modes (MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, MODE_APPEND, MODE_MULTI_PROCESS )

Shared Preferences

Page 24: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Shared Preferences

● Get an instancesharedPreferences = context.getSharedPreferences(PREFS_FILE_NAME, MODE_PRIVATE);

● Get value of a key

sharedPreferences.getString(key, "")

● Set value of a key

sharedPreferences.edit().putString(key, value).commit();

● Remove a key-value

sharedPreferences.edit().remove(key).commit();

Let’s see usage in source code ApplicationContext.java https://github.com/proverbface/MaterialDesign/

Page 25: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Resources

Page 26: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Support Libraries

compile 'com.android.support:appcompat-v7:22.+'

compile 'com.android.support:recyclerview-v7:22.+'

compile 'com.android.support:cardview-v7:22.+'

compile 'com.android.support:design:22.2.0'

Support LibrariesSupport Library: http://developer.android.com/tools/support-library/index.htmlDesign Support Library: http://android-developers.blogspot.co.nz/2015/05/android-design-support-library.htmlCards and RecyclerView: https://developer.android.com/training/material/lists-cards.html

Activity & Fragment

Activity Documentation: http://developer.android.com/training/basics/activity-lifecycle/index.html

Fragment Documentation: http://developer.android.com/guide/components/fragments.html

Resources

Page 27: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Android Studio

Download IDE: https://developer.android.com/sdk/index.html

Android Studio Overview: https://developer.android.com/tools/studio/index.html

Design

Material Design: https://www.google.com/design/spec/material-design/introduction.htmlMaterial Design Icons: https://google.github.io/material-design-iconsGoogle Design: http://www.google.com/design

Youtube Dev ChannelsGoogle Developers: https://www.youtube.com/channel/UC_x5XG1OV2P6uZZ5FSM9Ttw

Android Developers: https://www.youtube.com/channel/UCVHFbqXqoYvEWM1Ddxl0QDg

Source Code:Follow @proverbface at Github and fork: https://github.com/proverbface/MaterialDesign

Resources

Page 28: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Android Development Community

Android Lollipop 5.0-5.1API Documentation: http://developer.android.com/about/versions/lollipop.html

Lollipop 5.0: http://www.android.com/versions/lollipop-5-0/

Android M PreviewAPI Overview: http://developer.android.com/preview/api-overview.html

Article: http://gizmodo.com/android-m-is-here-and-so-is-googles-smartphone-future-1707461388

What’s new in Android: https://www.youtube.com/watch?v=ndBdf1_oOGA

Books and CertificationsUdacity: https://www.udacity.com

ATC Academy: http://www.androidatc.com

OCA/OCP Java SE 7: http://www.amazon.com/Programmer-Study-1Z0-803-1Z0-804-Certification/dp/0071772006

Resources

Page 29: Welcome to Android Android Development Community to Android - 22-06-2015… · Android Development Community Applications is the layer were system and developer apps run. Application

Questions?

Android Development Community

Juan Pablo [email protected]