




























































































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Prepara i tuoi esami
Studia grazie alle numerose risorse presenti su Docsity
Prepara i tuoi esami con i documenti condivisi da studenti come te su Docsity
Trova i documenti specifici per gli esami della tua università
Preparati con lezioni e prove svolte basate sui programmi universitari!
Rispondi a reali domande d’esame e scopri la tua preparazione
Riassumi i tuoi documenti, fagli domande, convertili in quiz e mappe concettuali
Studia con prove svolte, tesine e consigli utili
Togliti ogni dubbio leggendo le risposte alle domande fatte da altri studenti come te
Esplora i documenti più scaricati per gli argomenti di studio più popolari
Ottieni i punti per scaricare
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Una panoramica su come utilizzare android studio per sviluppare app android. Comprende informazioni su come creare il tuo primo progetto, la struttura del progetto, la creazione di layout e viste a scorrimento, l'uso di textview e di controlli di input, e come gestire risorse. Inoltre, vengono fornite informazioni su come utilizzare la libreria di supporto di android, menù e dialoghi, e come testare e ottimizzare l'app.
Tipologia: Dispense
1 / 434
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!





























































































Introduction Unit 1. Get started Lesson 1: Build your first app 1.0: Introduction to Android 1.1: Create Your First Android App 1.2: Layouts, Views and Resources 1.3: Text and Scrolling Views 1.4: Resources to Help You Learn Lesson 2: Activities 2.1: Understanding Activities and Intents 2.2: The Activity Lifecycle and Managing State 2.3: Activities and Implicit Intents Lesson 3: Testing, debugging, and using support libraries 3.1: The Android Studio Debugger 3.2: Testing your App 3.3: The Android Support Library Unit 2. User experience Lesson 4: User interaction 4.1: User Input Controls 4.2: Menus 4.3: Screen Navigation 4.4: RecyclerView Lesson 5: Delightful user experience 5.1: Drawables, Styles, and Themes 5.2: Material Design 5.3: Providing Resources for Adaptive Layouts Lesson 6: Testing your UI 6.1: Testing the User Interface Unit 3. Working in the background Lesson 7: Background Tasks 7.1: AsyncTask and AsyncTaskLoader 7.2: Connect to the Internet 7.3: Broadcast Receivers 7.4: Services Lesson 8: Triggering, scheduling and optimizing background tasks 8.1: Notifications 8.2: Scheduling Alarms 8.3: Transferring Data Efficiently Unit 4. All about data
Table of Contents
Android Developer Fundamentals is a training course created by the Google Developer Training team. You learn basic Android programming concepts and build a variety of apps, starting with Hello World and working your way up to apps that use content providers and loaders.
Android Developer Fundamentals prepares you to take the exam for the Associate Android Developer Certification.
This course is intended to be taught in a classroom, but all the materials are online, so if you like to learn by yourself, go ahead!
Android Developer Fundamentals is intended for new and experienced developers who already have Java programming experience and now want to learn to build Android apps.
The course materials include:
This concept reference, which teaches subjects you need to learn to complete the exercises in the practical workbook. Some lessons are purely conceptual and do not have an accompanying practical. The practical workbook: Android Developer Fundamentals Course—Practicals Slide decks (for optional use by instructors) Videos of lectures (for reference by instructors and students)
Android Developer Fundamentals includes five teaching units, which are described in What does the course cover?
Developed by the Google Developer Training Team
Introduction
Last updated: February 2017
This work is licensed under a Creative Commons Attribution-Non Commercial 4.0 International License
Introduction
content.
Android provides a touch-screen user interface (UI) for interacting with apps. Android's user interface is mainly based on direct manipulation, using touch gestures such as swiping, tapping and pinching to manipulate on-screen objects. In addition to the keyboard, there’s a customizable virtual keyboard for text input. Android can also support game controllers and full-size physical keyboards connected by Bluetooth or USB.
The Android home screen can contain several pages of app icons , which launch the associated apps, and widgets , which display live, auto-updating content such as the weather, the user's email inbox or a news ticker. Android can also play multimedia content such as music, animation, and video. The figure above shows app icons on the home screen (left), playing music (center), and displaying widgets (right). Along the top of the screen is a status bar, showing information about the device and its connectivity. The Android home screen may be made up of several pages, between which the user can swipe back and forth.
Android is designed to provide immediate response to user input. Besides a fluid touch interface, the vibration capabilities of an Android device can provide haptic feedback. Internal hardware such as accelerometers, gyroscopes and proximity sensors, are used by many apps to respond to additional user actions. These sensors can detect rotation of the screen from portrait to landscape for a wider view or it can allow the user to steer a virtual vehicle in a racing game by rotating the device as if it were a steering wheel.
1.0: Introduction to Android
The Android platform, based on the Linux kernel, is designed primarily for touchscreen mobile devices such as smartphones and tablets. Since Android devices are usually battery-powered, Android is designed to manage processes to keep power consumption at a minimum, providing longer battery use.
Use the Android software development kit (SDK) to develop apps that take advantage of the Android operating system and UI. The SDK includes a comprehensive set of development tools including a debugger, software libraries of prewritten code, a device emulator, documentation, sample code, and tutorials. Use these tools to create apps that look great and take advantage of the hardware capabilities available on each device.
To develop apps using the SDK, use the Java programming language for developing the app and Extensible Markup Language (XML) files for describing data resources. By writing the code in Java and creating a single app binary, you will have an app that can run on both phone and tablet form factors. You can declare your UI in lightweight sets of XML resources, one set for parts of the UI that are common to all form factors, and other sets for features specific to phones or tablets. At runtime, Android applies the correct resource sets based on its screen size, density, locale, and so on.
To help you develop your apps efficiently, Google offers a full Java Integrated Development Environment (IDE) called Android Studio, with advanced features for developing, debugging, and packaging Android apps. Using Android Studio, you can develop on any available Android device, or create virtual devices that emulate any hardware configuration.
Android provides a rich development architecture. You don’t need to know much about the components of this architecture, but it is useful to know what is available in the system for your app to use. The following diagram shows the major components of the Android stack — the operating system and development architecture.
In the figure above:
1.0: Introduction to Android
N/A 1.1 9 February 2009 2
Cupcake 1.5 27 April 2009 3
Donut
1.6 15 September 2009 4
Eclair
2.0 – 2.1 26 October 2009 5–
Froyo
2.2 – 2.2.3 20 May 2010 8
Gingerbread
1.0: Introduction to Android
2.3 – 2.3.7 6 December 2010 9–
Honeycomb
3.0 – 3.2.6 22 February 2011 11–
Ice Cream Sandwich
4.0 – 4.0.4 18 October 2011 14–
Jelly Bean
1.0: Introduction to Android
6.0 – 6.0.1 5 October 2015 23
Nougat
7.0 22 August 2016 24
See previous versions and their features at The Android Story.
The Dashboard for Platform Versions is updated regularly to show the distribution of active devices running each version of Android, based on the number of devices that visit the Google Play Store. It's a good practice to support about 90% of the active devices, while targeting your app to the latest version.
Note: To provide the best features and functionality across Android versions, use the Android Support Library in your app. This support library allows your app to use recent platform APIs on older devices.
The challenges of Android app development
While the Android platform provide rich functionality for app development, there are still a number of challenges you need to address, such as:
Building for a multi-screen world Getting performance right Keeping your code and your users secure Remaining compatible with older platform versions Understanding the market and the user.
1.0: Introduction to Android
Android runs on billions of handheld devices around the world, and supports various form factors including wearable devices and televisions. Devices can come in different sizes and shapes that affect the screen designs for UI elements in
your apps.
In addition, device manufacturers may add their own UI elements, styles, and colors to differentiate their products. Each manufacturer offers different features with respect to keyboard forms, screen size, or camera buttons. An app running on one device may look a bit different on another. The challenge for many developers is to design UI elements that can work on all devices It is also the developer’s responsibility to provide an app’s resources such as icons, logos, other graphics, and text styles to maintain uniformity of appearance across different devices.
An app's performance—how fast it runs, how easily it connects to the network, and how well it manages battery and memory usage—is affected by factors such as battery life, multimedia content, and Internet access. You must be aware of these limitations and write code in such a way that the resource utilization is balanced and distributed optimally. For example, you will have to balance the background services by enabling them only when necessary; this will save battery life of the user’s device.
You need to take precautions to secure your code and the user’s experience when using your app. Use tools such as ProGuard (provided in Android Studio), which detects and removes unused classes, fields, methods, and attributes, and encrypt all of your app's code and resources while packaging the app. To protect your user's critical information such as logins and passwords, you must secure the communication channel to protect data in transit (across the Internet) as well as data at rest (on the device).
Consider how to add new Android platform version features to an app, while ensuring that the app can still run on devices with older platform versions. It is impractical to focus only on the most recent Android version, as not all users may have upgraded or may be able to upgrade their devices.
Learn more
The Android Story Android API Guide, "Develop" section: Introduction to Android Platform Architecture
1.0: Introduction to Android
Contents:
The development process Using Android Studio Exploring a project Viewing and editing Java code Viewing and editing layouts Understanding the build process Running the app on an emulator or a device Using the log Related practical Learn more
This chapter describes how to develop applications using the Android Studio Integrated Development Environment (IDE).
An Android app project begins with an idea and a definition of the requirements necessary to realize that idea. As the project progresses, it goes through design, development, and testing.
The above diagram is a high-level picture of the development process, with the following steps:
Defining the idea and its requirements: Most apps start with an idea of what it should do, bolstered by market and user research. During this stage the app's requirements are defined. Prototyping the user interface: Use drawings, mock ups and prototypes to show what the user interface would look like, and how it would work. Developing and testing the app: An app consists of one or more activities. For each activity you can use Android Studio to do the following, in no particular order: Create the layout: Place UI elements on the screen in a layout, and assign string resources and menu items, using the Extensible Markup Language (XML). Write the Java code: Create source code for components and tests, and use testing and debugging tools. Register the activity: Declare the activity in the manifest file. Define the build: Use the default build configuration or create custom builds for different versions of your app. Publishing the app : Assemble the final APK (package file) and distribute it through channels such as the Google Play.
1.1: Create Your First Android App
Android Studio provides tools for the testing, and publishing phases of the development process, and a unified development environment for creating apps for all Android devices. The development environment includes code templates with sample code for common app features, extensive testing tools and frameworks, and a flexible build system.
After you have successfully installed the Android Studio IDE, double-click the Android Studio application icon to start it. Choose Start a new Android Studio project in the Welcome window, and name the project the same name that you want to use for the app.
When choosing a unique Company Domain, keep in mind that apps published to the Google Play must have a unique package name. Since domains are unique, prepending the app's name with your name, or your company's domain name, should provide an adequately unique package name. If you are not planning to publish the app, you can accept the default example domain. Be aware that changing the package name later is extra work.
When choosing Target Android Devices, Phone and Tablet are selected by default, as shown in the figure below. The choice shown in the figure for the Minimum SDK — API 15: Android 4.0.3 (IceCreamSandwich) — makes your app compatible with 97% of Android devices active on the Google Play Store.
Different devices run different versions of the Android system, such as Android 4.0.3 or Android 4.4. Each successive version often adds new APIs not available in the previous version. To indicate which set of APIs are available, each version specifies an API level. For instance, Android 1.0 is API level 1 and Android 4.0.3 is API level 15.
The Minimum SDK declares the minimum Android version for your app. Each successive version of Android provides compatibility for apps that were built using the APIs from previous versions, so your app should always be compatible with future versions of Android while using the documented Android APIs.
Android Studio pre-populates your project with minimal code for an activity and a screen layout based on a template. A variety of templates are available, ranging from a virtually blank template (Add No Activity) to various types of activities.
1.1: Create Your First Android App
The Android Studio main window is made up of several logical areas, or panes , as shown in the figure below.
In the above figure:
Tip : You can organize the main window to give yourself more screen space by hiding or moving panes. You can also use keyboard shortcuts to access most features. See Keyboard Shortcuts for a complete list.
Exploring a project
Each project in Android Studio contains the AndroidManifest.xml file, component source-code files, and associated resource files. By default, Android Studio organizes your project files based on the file type, and displays them within the Project: Android view in the left tool pane, as shown below. The view provides quick access to your project's key files.
1.1: Create Your First Android App
To switch back to this view from another view, click the vertical Project tab in the far left column of the Project pane, and choose Android from the pop-up menu at the top of the Project pane, as shown in the figure below.
In the figure above:
Before the Android system can start an app component, the system must know that the component exists by reading the app's AndroidManifest.xml file. The app must declare all its components in this file, which must be at the root of the app project directory.
1.1: Create Your First Android App