1 / 44

Android

Discover the ins and outs of Android development with this comprehensive guide. Learn about Android components, application lifecycle, UI controls, event handling, SQLite databases, web services, and more. Get started with installing Android Studio and dive into the world of creating dynamic Android applications.

juliad
Download Presentation

Android

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Android

  2. Contents • Introduction to Android. • How to install Android Studio • Application components • Life cycle of Android • UI Controls • Layout Designing • Event Handling • Adapters • Styles and themes ,Creating dialogs • Tabs • SqLite Database • WebServices • Google Maps

  3. What is Android? Android is an open source and Linux-based operating system for mobile devices such as smartphones and tablet computers. Android was developed by the Open Handset Alliance, led by Google, and other companies.

  4. Introduction to Android • Android is a complete set of software for mobile devices such as tablet computers, notebooks, smartphones, electronic book readers, set-top boxes etc. • Android applications are usually developed in the Java language using the Android Software Development Kit. • It contains a linux-based Operating System, middleware and key mobile applications. • It can be thought of as a mobile operating system. But it is not limited to mobile only. It is currently used in various devices such as mobiles, tablets, televisions etc…

  5. Why Android ?

  6. History of Android The code names of android ranges from A to O currently, such as Aestro , Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream Sandwitch , Jelly Bean, KitKat ,Lollipop, Marshmallow and latest Oreo • Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States in October, 2003. • In 17th August 2005, Google acquired android Incorporation. Since then, it is in the subsidiary of Google Incorporation. • The key employees of Android Incorporation are Andy Rubin, Rich Miner, Chris White and Nick Sears. • Originally intended for camera but shifted to smart phones later because of low market for camera only. • Android is the nick name of Andy Rubin given by coworkers because of his love to robots. • In 2007, Google announces the development of android OS. • In 2008, HTC launched the first android mobile.

  7. Features of Android • Connectivity GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and WiMAX. • Storage SQLite, a lightweight relational database, is used for data storage purposes. • Media support H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3, MIDI, OggVorbis, WAV, JPEG, PNG, GIF, and BMP. • Messaging SMS and MMS. • Web browser Based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript engine supporting HTML5 and CSS3. • Multi-touch Android has native support for multi-touch which was initially made available in handsets such as the HTC Hero.

  8. Multi-tasking User can jump from one task to another and same time various application can run simultaneously. • Resizable widgets Widgets are resizable, so users can expand them to show more content or shrink them to save space. • Multi-Language Supports single direction and bi-directional text. • GCM Google Cloud Messaging (GCM) is a service that lets developers send short message data to their users on Android devices, without needing a proprietary sync solution. • Wi-Fi Direct A technology that lets apps discover and pair directly, over a high-bandwidth peer-to-peer connection. • Android Beam A popular NFC-based technology that lets users instantly share, just by touching two NFC-enabled phones together.

  9. API levels API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android Platform.

  10. Android Architecture

  11. How to install Android Studio? • InstallJDKfile from the link below. http://www.oracle.com/technetwork/java/javase/downloads/index.html • Now download Android Studio. https://developer.android.com/studio/index.html

  12. Application components Application components are the essential building blocks of an Android application. These components are loosely coupled by the application manifest file AndroidManifest.xml that describes each component of the application and how they interact. • Activities An activity represents a single screen with a user interface. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. • Services A service is a component that runs in the background to perform long- running operations. For example, an application like music player. Service might play music in the background while the user is in a different application. • Broadcast Receiver Broadcast Receivers simply respond to broadcast messages from other applications or from the system.

  13. For example, applications can also initiate broadcasts to let other applications know that some data has been downloaded to the device and is available for them to use, so this is broadcast receiver who will intercept this communication and will initiate appropriate action. • Content provider A content provider component supplies data from one application to others on request. Such requests are handled by the methods of theContent Resolver class. The data may be stored in the file system, the database or somewhere else entirely.

  14. Hello World Program The first step is to create a simple Android Application using Android studio. When you click on Android studio icon, it will show screen as shown below

  15. You can start your application development by calling start a new android studio project. in a new installation frame should ask Application name, package information and location of the project.−

  16. After entered application name, it going to be called select the form factors your application runs on, here need to specify Minimum SDK, in our tutorial, I have declared as API23: Android 6.0(Mashmallow)

  17. The next level of installation should contain selecting the activity to mobile, it specifies the default layout for Applications.

  18. At the final stage it going to be open development tool to write the application code.

  19. Resources • Java This contains the .java source files for your project. By default, it includes anMainActivity.java source file having an activity class that runs when your app is launched using the app icon. • res/drawable-hdpi This is a directory for drawable objects that are designed for high-density screens. • res/layout This is a directory for files that define your app's user interface. • res/values This is a directory for other various XML files that contain a collection of resources, such as strings and colours definitions. • 5. AndroidManifest.xml This is the manifest file which describes the fundamental characteristics of the app and defines each of its components. This file works as an interface between Android OS and your application, so if you do not declare your component in this file, then it will not be considered by the OS. • 6. Build.gradle This is an auto generated file which contains compileSdkVersion, buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, versionCode and versionName .

  20. Life cycle of Android • Activity Android system initiates its program with in an Activity starting with a call ononCreate() callback method.

  21. onCreate() This is the first callback and called when the activity is first created. • onStart() This callback is called when the activity becomes visible to the user. • onResume() This is called when the user starts interacting with the application. • onPause() The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed. • onStop() This callback is called when the activity is no longer visible. • onDestroy() This callback is called before the activity is destroyed by the system. • onRestart() This callback is called when the activity restarts after stopping it.

  22. Types of Layouts

  23. UI Controls A View is an object that draws something on the screen that the user can interact with and a ViewGroup is an object that holds other View (and ViewGroup) objects in order to define the layout of the user interface. • TextView This control is used to display text to the user. • EditText EditTextis a predefined subclass of TextView that includes rich editing capabilities. • AutoCompleteTextView The AutoCompleteTextView is a view that is similar to EditText, except that it shows a list of completion suggestions automatically while the user is typing. • Button A push-button that can be pressed, or clicked, by the user to perform an action. • ImageButton An ImageButton is an AbsoluteLayout which enables you to specify the exact location of its children. This shows a button with an image (instead of text) that can be pressed or clicked by the user.

  24. Check box An on/off switch that can be toggled by the user. You should use check box when presenting users with a group of selectable options that are not mutually exclusive. • Toggle Button An on/off button with a light indicator. • RadioButton The RadioButtonhas two states: either checked or unchecked. • RadioGroup A RadioGroup is used to group together one or more RadioButtons. • Spinner A drop-down list that allows users to select one value from a set.

  25. Fragment • A fragment represent a behavior or a portion of user interface in an Activity. • You can combine multiple fragments in a single activity to build a multi-pane UI  • A fragment must always be embedded in an activity and the fragment's lifecycle is directly affected by the host activity's lifecycle • When you add a fragment as a part of your activity layout, it lives in a ViewGroupinside the activity's view. • To create a fragment, you must create a subclass of Fragment.

  26. List of methods which you can to override in your fragment class • onAttach() The fragment instance is associated with an activity instance.The fragment and the activity is not fully initialized. Typically you get in this method a reference to the activity which uses the fragment for further initialization work. • onCreate() The system calls this method when creating the fragment. You should initialize essential components of the fragment that you want to retain when the fragment is paused or stopped, then resumed. • onCreateView() The system calls this callback when it's time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a View component from this method that is the root of your fragment's layout. You can return null if the fragment does not provide a UI. • onActivityCreated() The onActivityCreated() is called after the onCreateView() method when the host activity is created. Activity and fragment instance have been created as well as the view hierarchy of the activity. At this point, view can be accessed with the findViewById() method. example. In this method you can instantiate objects which require a Context object

  27. onStart() The onStart() method is called once the fragment gets visible. • onResume() Fragment becomes active. • onPause() The system calls this method as the first indication that the user is leaving the fragment. This is usually where you should commit any changes that should be persisted beyond the current user session • onStop() Fragment going to be stopped by calling onStop() • onDestroyView() Fragment view will destroy after call this method • onDestroy() onDestroy() called to do final clean up of the fragment's state but Not guaranteed to be called by the Android platform.

  28. Text to Speech program • https://www.androidhive.info/2012/01/android-text-to-speech-tutorial/

  29. Layout design Register and Login

  30. Event Handling • onClick() This is called when the user either clicks or touches or focuses upon any widget like button, text, image etc. You will use onClick() event handler to handle such event. • onLongClick() This is called when the user either clicks or touches or focuses upon any widget like button, text, image etc. for one or more seconds. You will use onLongClick() eventhandlerto handle such event. • onFocusChange() This is called when the widget looses its focus ie. user goes away from the view item. You will use onFocusChange() event handler to handle such event. • onTouch() This is called when the user presses the key, releases the key, or any movement gesture on the screen. You will use onTouch() event handler to handle such event.

  31. onMenuItemClick() This is called when the user selects a menu item. You will use onMenuItemClick() event handler to handle such event. • onCreateContextMenu() This is called when the context menu is being built(as the result of a sustained "long click)

  32. Adapters • In Android, Adapter is a bridge between UI component and data source that helps us to fill data in UI component. • It holds the data and send the data to an Adapter view then view can takes the data from the adapter view and shows the data on different views like as ListView, GridView, Spinner etc. For more customization in Views we uses the base adapter or custom adapters. Common Adapters • BaseAdapter – It is parent adapter for all other adapters • ArrayAdapter – It is used whenever we have a list of single items which is backed by an array. • Custom ArrayAdapter – It is used whenever we need to display a custom list • SimpleAdapter – It is an easy adapter to map static data to views defined in your XML file • Custom SimpleAdapter – It is used whenever we need to display a customized list and needed to access the child items of the list or grid

  33. ListView & GridView • Android ListView & GridView is a view which groups several items and display them in vertical scrollable list in listview and with different column in gridview. • The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database. • Example Simple list : https://androidexample.com/Create_A_Simple_Listview_- _Android_Example/index.php?view=article_discription&aid=65 • Example Base adapter : http://theopentutorials.com/tutorials/android/listview/android-custom-listview- with-image-and-text-using-baseadapter/ http://theopentutorials.com/tutorials/android/listview/android-custom-listview-with-image-and-text-using-baseadapter/

  34. RecyclerView • Android RecyclerView is more advanced version of ListView with improved performance and other benefits. • ViewHolder Pattern In a ListView, it was recommended to use the ViewHolder pattern but it was never a compulsion. In case of RecyclerView, this is mandatory using theRecyclerView.ViewHolder class. This is one of the major differences between the ListView and the RecyclerView. • LayoutManager This is another massive enhancement brought to the RecyclerView. In a ListView, the only type of view available is the vertical ListView. There is no official way to even implement a horizontal ListView. • Now using a RecyclerView, we can have a i) LinearLayoutManager - which supports both vertical and horizontal lists, ii) StaggeredLayoutManager - which supports Pinterest like staggered lists, iii) GridLayoutManager - which supports displaying grids as seen in Gallery apps. And the best thing is that we can do all these dynamically as we want.

  35. SQLite Database •  SQLite is one way of storing user data. • SQLite is an open-source relational database i.e. used to perform database operations on android devices such as storing, manipulating or retrieving persistent data from the database. • SQLiteOpenHelper class provides the functionality to use the SQLite database. very light weight database which comes with Android OS. • The android.database.sqlite.SQLiteOpenHelper class is used for database creation and version management. For performing any database operation, you have to provide the implementation of onCreate() and onUpgrade() methods of SQLiteOpenHelper class.

  36. Methods of SQLiteOpenHelper class

  37. Methods of SQLiteDatabase class

  38. Web service • A web service is a standard for exchanging information between different types of applications irrespective of language and platform. • Web service with JSON • Web service with Retrofit 2.

  39. Multimedia in Android • Multimedia Audio player Example:https://www.javatpoint.com/playing-audio-in-android-example • Multimedia Video player Example: https://www.javatpoint.com/playing-video-in-android-example

  40. Animation • Example: https://www.tutorialspoint.com/android/android_animations.htm

  41. Accessing android hardware • Example: https://www.tutorialspoint.com/android/android_camera.htm

  42. Google maps • Android allows us to integrate google maps in our application. You can show any location on the map , or can show different routes on the map e.t.c. You can also customize the map according to your choices. • Customizing Google Map You can place a maker with some text over it displaying your location on the map. It can be done by via addMarker() method. • Channing Map Type You can also change the type of the MAP. There are four different types of map and each give different view of the map. These types are Normal,Hybrid,Satelliteand terrain.  • Enable/Disable zoom You can also enable or disable the zoom gestures in the map by calling thesetZoomControlsEnabled(boolean) method. • Example: https://www.androidhive.info/2015/02/android-location-api-using-google-play-services/

More Related