welcome to android android development community to android - 22-06-2015… · android development...
TRANSCRIPT
Welcome to Android
Android Development Community
“Be together. Not the same.”
Agenda
● What and Who is Android● Android Architecture● Android Studio● Activity and Fragment● Shared Preferences● Resources
Android Development Community
Android Development Community
Android
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?
Source: http://www.recruitit.co.nz/remuneration/it-salaries-new-zealand/
Android Salariesfrom
50k Junior
70k Intermediate
75k-90k Senior
90k to 110k Lead
Android Currently
Owns 78% of theWorldwide
Smartphone OSMarket Share
With billions of devices
Source: http://www.idc.com/prodserv/smartphone-os-market-share.jsp
Android Development Community
Android Architecture
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
Android Development Community
Android Studio
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
Android Development Community
Activity
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
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
Android Development Community
Activity Lifecycle
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/
Android Development Community
Fragment
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
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
Android Development Community
Fragment Lifecycle
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/
Android Development Community
Shared Preferences
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
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/
Android Development Community
Resources
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
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
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