Mobile Programming Final

Ace your homework & exams now with Quizwiz!

Internal Storage

Another option when saving persistent data is to store the information directly on the device's internal drive. The saved files on the device are available only to the app that created the files. Other applications cannot access files saved with the internal storage method. Use caution when storing internal files, because low internal storage space can drastically affect the speed of an Android device and battery life.

WebView object

a View widget that displays webpages. The WebView object allows you to place a web browser or simply display some online content within your Activity. The WebView object uses a built-in rendering engine to display webpages.

Images

a powerful marketing tool and add visual appeal to any Android application, but it is essential to create a clean, professional effect with those images.

View container

a rectangular area of the screen that displays an image or text object.

Java method

a series of statements that perform some repeated task

padding property

can be used to offset the content of the control by a specific number of pixels.

A calendar tool called a DatePicker control is

displayed in a dialog box to determine the user's preferred date for a full-day fishing trip

GridView container

displays a horizontal list of objects with the center item displaying the current image

How to instantiate a custom BaseAdapter class called ImageAdapter and apply it to the GridView using setAdapter( ):

grid.setAdapter(new ImageAdapter(this));

A special image, called a 9-patch image,

has predefined "stretching" areas that maintain the same look on different screen sizes. These 9-patch graphics are named for their nine areas, called patches, that scale separately

Native applications

programs locally installed on a specific platform such as a phone or tablet A native application is typically designed for a specific platform such as a phone on a 5-inch screen or a tablet on a 10.1-inch screen.

setAdapter

provides a data model for the GridView layout

AnimationDrawable class

provides the methods for drawable animations to create a sequence of frame-by-frame images

When the user selects a date from the DatePickerDialog,

, the onDateSet( ) method automatically obtains the date selected by the user. Three portions of the date must be set for the YEAR, MONTH, and DAY_OF_MONTH of the new reservation.

The ImageAdapter class must provide the information to set up the GridView with data and specifications necessary for the display.

A Context variable is used to load and access resources for the application.

After placing the WebView object in the XML layout of the app, you must add Internet permissions to the Android Manifest file in order for your Activity to access the Internet and load webpages.

A permission is a restriction limiting access to a part of the code or to data on the device. The permission protects critical data and code that could be misused to cause issues for your app and others. Permissions can be set in the Android Manifest file within an Android app to allow certain actions such as to set the background wallpaper, check the device's power levels, read your contacts, write events to your calendar, and display a webpage.

onItemClick

AdapterView<?> parent - The AdapterView records "where" the user actually touched the screen in the argument variable parent. In other words, if the app has more than one View control, the AdapterView determines if the user touched this GridView control or another control in the application. View view - The View parameter is the specific View within the item that the user touched. This is the View provided by the adapter. int position - This is one of the most important portions of this statement in the chapter project. The position argument is an integer value that holds the position of the View in the adapter long id - The GridView control is displayed across multiple rows of the Android device. The argument id determines the row id of the item that was selected by the user. This is especially useful for a GridView control that has multiple rows in the layout.

When the XML file is added to the Android project, the Android resource type is selected and animation-list is specified as the root element of the XML code.

An animation-list displays a listing of the images in the preferred order. Store the animations.xml file in the drawable folder. To copy the images into the drawable folder and code the animation-list XML code for the frame-by-frame animation

External Storage

Android apps can save persistent data to external storage, for example, the device's SD (Secure Digital) card. All applications can read and write files placed on the external storage and the Android smartphone or tablet owner can remove them.

The instance of AnimationDrawable called lightsAnimation is assigned as the background of the four images to display in the animation.

Android constructs an AnimationDrawable Java object before setting it as the background.

Android tablet sales are successfully competing with the

Apple iPad

Now that the layout, rotation XML file, and second Activity are ready, the Tween animation can be launched using the StartAnimation method

Applying the Tween rotation animation, the StartAnimation method begins animating a View object by calling the AnimationUtils class utilities to access the resources necessary to load the animation.

A fragment is essentially a sub-Activity hosted inside another Activity.

By dividing components of the user interface and displaying them in fragments, it is easier for developers to reuse these components across various Activities.

. The ImageAdapter constructor is changed from the MainActivity to handle the Context resources necessary for the GridView.

Constructors are used to initialize the instance variables of an object. Constructors enable the programmer to set default values, limit instantiation, and write code that is flexible and easy to read. This command is called a constructor because it constructs the values of data members of the class.

Android provides two types of animation: Frame and Tween animation.

Frame animation, also called frame-by-frame animation, assigns a sequence of photos to play as in a slide show with a predefined interval between images. Frame-by-frame animation is typically created to show steps in a process such as how to fly-fish or to play a fast-paced sequence such as in a cartoon.

Grid View Syntax

GridView grid = (GridView)findViewById(R.id.gridView);

A View container can include layouts such as

GridView, RadioGroup, ScrollView, TabHost, and ListView

SQLite

If you have a large amount of data to store as persistent data, a database is the perfect choice. The default database engine for Android is SQLite. SQLite (SQL stands for Structured Query Language) is a lightweight, preloaded mobile database engine, which has been available since the Cupcake 1.5 version of Android and occupies a small amount of disk memory. The data is stored within the SQLite database so that it persists even after the app is terminated. In contrast to a traditional database, SQLite is embedded into the user's program or browser. Using a SQLite database, Android apps model data items in tables and columns, with optional relationships between the entities within the database. The tables can be queried using SQL statements.

Network Connection

If your device is connected to the Internet, persistent data can be stored and retrieved on a web service. Before an app attempts to connect to a network connection, it should check to see whether an Internet connection is available. The device may be out of range of a 3G/4G network or the user may have disabled both Wi-Fi and mobile data access. If a connection is not available, the user cannot save or retrieve the persistent data.

Java Files

ItemDetailActivity.java: The purpose of this class is to display the activity_item_detail.xml layout file if a smartphone is detected. ItemDetailFragment.java: The purpose of this class is to display the fragment_item_detail.xml layout file. This class can be customized to determine which detailed items to display. ItemListActivity.java: The purpose of this initial Activity is to display the master list in a twopane mode if a tablet device is detected or to launch a second Activity to display the detail items if a smaller device is detected. ItemListFragment.java: The purpose of this class is to display the activity_item_list.xml layout file. DummyContent.java: The purpose of this Java file is to provide sample code you customize to suit your specific app content. Five

The SharedPreferences class provides one of the easiest ways to save and load primitive data, whether you are looking to save the user's name or settings such as the font size the user prefers.

Shared preferences can save any data including user preferences, such as what wallpaper a user has chosen or individual values entered by the user in an EditText control. Shared preferences can be used to save any primitive data: Booleans, floats, ints, longs, and strings. Shared preferences are best when your app needs to save small chunks of data such as a name-value pair.

application templates

The Android Studio software development kit provides tools for quickly creating Android apps that follow the Android design and development guidelines and include code that can be customized to the exact needs of your app

Every Android application must have an AndroidManifest.xml file in its app directory. The Android Manifest file presents essential information about an app to the Android system, information the system must have before it can run the code of the application.

The AndroidManifest.xml file declares the theme, each Activity run within the application, and permissions necessary for the application to interact with other applications. Without the proper permission, attempts to access the Internet or complete similar actions will fail.

The three navigation buttons centered on the bottom of the Android tablet are Back, Home, and Multitasking.

The Back button returns to the previous action. The Home button returns to the default home screen. The Multitasking button opens a list of the apps that have been used recently.

To reach a larger audience within the Google Play market, consider targeting multiple Android devices and translating your app into multiple languages.

The Translations Editor within Android Studio supports multiple languages

The length of an array is determined by the number of elements in the array.

The getCount( ) method must return the number of elements in the GridView in order to create the correct layout for the GridView control.

The most powerful method in the ImageAdapter class is the getView( ) method

The getView( ) method uses Context to create a new ImageView instance that temporarily holds each image displayed in the GridView. In addition, the ImageView is scaled to fit the GridView control and sized according to a custom height and width.

In Android development, frame-based animations and image transitions are defined as drawables.

The instance of AnimationDrawable is instantiated as a class variable because it is used in multiple methods within the MainActivity class.

One of the most effective ways to save simple application data to an Android device is by using the SharedPreferences object. The data is saved to an XML file as a key-value pair.

The key is a string such as "key1" that uniquely identifies the preference, and the value is the data represented as a string, int, long, float, or Boolean. Android SharedPreferences can store data that can be used in different Activities of your application or by another application.

The Master/Detail Flow template provides a folder named dummy in the net. androidbootcamp.bikeandbarge folder that contains a Java class file named DummyContent. java.

The purpose of this class is to provide sample content to display in the user interface of the template.

After testing and refining your Android application, you must create a release-ready package that users can install and run on their Android phones and tablets.

The release-ready package is called an .apk file (application package file), which is a compressed archive similar to a .zip file that contains the application, the manifest file, and all associated resources, such as image files, music, and other required content. Google created the .apk file format

The list of drawable images in the animation-list is connected to the imgFrame instance by the imgFrame.setBackgroundResource method

The setBackgroundResource method shown in the following code places the four Northern Lights images in the frame-by-frame slide type display. Each frame points to one of the Northern Lights images that were assembled in the XML resource file. The imgFrame instance is the image that you want to animate and is set to the animation drawable as its background.

DatePickerDialog is launched in the onClick method, and must be passed the values for the present year, month, and day

The values for the present date must be set for the DatePicker to display today's date. When the DatePickerDialog opens, an OnDateSetListener is necessary to await the user's selection of the desired reservation date.

After the user taps the START TWEEN ANIMATION button, the Frame animation ends and a second Activity is launched.

This second Activity is named Tween.java, and it defines a second layout named activity_tween.xml with a single ImageView control identified as imgTween, referencing the fourth image named lights4 that will be rotated with Tween animation.

When the app launches the DatePickerDialog control after tapping the Button control, the Android system date is initially displayed, making it easier for the user to select a future date without having to move forward in a calendar from a date decades ago.

To access the system date, the variables are initialized and displayed for the present YEAR, MONTH, and DAY_OF_MONTH. Next, the DatePickerDialog control must await user interaction by coding an OnDateSetListener named d, which listens for a callback, indicating the user is done filling in the reservation date.

.equals method,

To determine if two String objects match exactly

== operator compares two objects to determine whether they are exactly the same object

Two strings may be different objects, but have the same exact characters. The .equals() method is used to compare strings for equality.

Scaling keeps or changes the aspect ratio of the image within the ImageView control.

When an image is scaled, the aspect ratio is changed; for example, the picture may be stretched horizontally, but not vertically.

The next method in the ImageAdapter class is the getCount( ) method.

When the ImageAdapter class is called, the getCount( ) method determines how many pictures should be displayed in the GridView control. It does so by finding the length of the Animals array, which references the pictures of the endangered species. To determine the length of an array, Java provides a method named length( ) that returns an integer value of any given string or array.

Layout Files

activity_item_detail.xml: When a smartphone is detected, the app uses this layout to display the FrameLayout instance. activity_item_list.xml(2): Contains two files: activity_item_list.xml is displayed when a smartphone is detected; the app uses this layout to display the master list fragment. activity_item_list.xml (sw600dp) is displayed when a tablet is detected; the app is displayed in a two-pane layout containing both the master item list fragment and the item detail container. fragment_item_detail.xml: When a smartphone or a tablet is detected, this layout file displays the detail pane using the onCreateView( ) method.

DatePickerDialog

allows you to select a date from a DatePicker View, the TimePickerDialog allows you to select a time from the TimePicker View, and ProgressDialog displays a progress bar below a message text box to inform you of how long a time-consuming operation is taking

Instead of rendering several images in a sequence in Frame animation, Tween animation manipulates a drawable image by adding tween effects

ame animation, Tween animation manipulates a drawable image by adding tween effects. Defined in an XML file, tween effects are transitions that change objects from one state to another. An ImageView or TextView object can move, rotate, grow, or shrink.

Within the XML layout file,

an Android property named padding is used to spread out the content displayed on the tablet.

Responsive design

an approach to designing apps and websites that provide an optimal viewing experience across as many devices as possible.

android:oneshot

attribute of the animation-list to false the animation plays repeatedly like a film until the Start Tween Animation button is tapped. If the oneshot attribute is set to true, the animation plays once and then stops and displays the last frame

After associating AnimationDrawable with the animation images and coding the buttons, you can use the start( ) and stop( ) methods of the drawable objects to control the Frame animation.

can use the start( ) and stop( ) methods of the drawable objects to control the Frame animation. When the user taps the Start Frame Animation button, the start( ) method begins the Frame animation continuously because oneshot is set to false. The Frame animation stops only when the user taps the Start Tween Animation button, which launches the stop( ) method and then initiates the startActivity, launching the second Activity named Tween.java

In contrast, an emulated application is

converted in real time to run on a variety of platforms such as a webpage, which can be displayed on various screen sizes through a browser.

Master/Detail Flow template

creates an adaptive, responsive layout for a set of list items and associated detail content. The Master/Detail Flow template is considered a responsive screen design.

Tween animation

creates an animation by performing a series of transformations on a single image such as position, size, rotation, and transparency on the contents of a View object. Text can fly across the screen, an image of an engine can be rotated to display different angles, or the transparency of an image can change from transparent to solid.

Google Play

is a digital repository that serves as the storefront for Android devices and apps. It includes an online store for paid and free Android apps as well as music, movies, books, and games. Android phones, tablets, and Google television can all access the Google Play services.

Localization

is the process of adapting an app or webpage to a language while considering cultural differences such as whether the language is read left-to-right or right-to-left, calendar layout, measurements, currency, number formats such as date and time, and traditions of your target audience.

GridView

layout which shows items in a two-dimensional scrolling grid

common Android application topic

managing calendars and time

onItemClick

method defined by OnItemClickListener provides a number of arguments, which are listed in the parentheses included in the line of code. The two controls—ListView and GridView—enable the Android device to monitor for tap or click events using the OnItemClickListener and onItemClick commands.

getBaseContext( )

method in another method (such as onItemClick) that is triggered only when the user touches the GridView control If you do, the getBaseContext( ) method obtains a Context instance.

A user interface design layout named TableLayout is composed of TableRow controls

one for each row in your table in activity_main.xml The contents of each TableRow are the view controls that will go in each cell of the table grid

The Android system date can be accessed by using the Java Calendar class, which is

responsible for converting between a Date object and a set of integer fields such as YEAR, MONTH, and DAY_OF_MONTH. Typically, an Android mobile device connects to a cell phone tower or wireless network, which automatically updates the time zone and date.

The purpose of the getCount( ) method is to

return the number of elements in the array

getlnstance

returns a calendar date or time based on the system settings

getTime( ) method

returns the time value in the Date object

Start Frame Animation

reveals the animated images frame by frame. When the user taps the Stop Frame Animation button, the frame-by-frame animation stops and the last image of the lights rotates several times using Tween animation.

animation-list

root element references four Northern Lights images stored in the drawable folder. Each item in the animation-list specifies how many milliseconds to display each image The animation-list code includes the oneshot property, which is set to true by default.

The field manipulation method called get accesses the system date or time

set changes the current date or time

typeface

sets the style of the text to font families that include monospace, sans_serif, and serif

motion tween

specifies a start state of an object, and then animates the object using a uniform transition type such as rotating a predetermined number of times or an infinite number of times.

Persistent data

stores values permanently by placing the information in a file. Android provides several options for you to save persistent application

A sequence of animation instructions defines

the Tween animation using either XML or Android code. In this chapter project, the application first displays a frame-by-frame animation. Code is added to the same application to display a second type of animation called a Tween rotation effect.

The date constants in this class are YEAR, MONTH, and DAY_OF_MONTH;

they retrieve an integer value of the system's current year, month, and day, respectively Another Calendar constant includes DAY_OF_YEAR, which displays the day number of the current year

A GridView control of images is typically

used to select a wallpaper image for the background of an Android device

fragment

which is a piece of an application's user interface or behavior that can be placed in an Activity

Using multimedia

within an Android program brings personality and imagery to your app.

After completing and adding locales to your Android app, you must test the app on various devices before publication. Using the built-in emulators in Android Studio, you can test the design and functionality of your app on a wide range of devices. You can also see how your development application will perform in a real-world environment by using Android Studio to install and test it directly on an Android phone. With an Android-powered device, you can develop and debug your Android applications just as you would on the emulator.

you can use a versatile tool called the Android Debug Bridge (ADB) to communicate with a connected Android device.

GridView is mainly useful when

you want to show data in a grid layout to display images or icons, for example. This layout can be used to build applications such as image viewers and audio or video players to show elements in a table or grid.

Persistent data can be stored in five different ways in Android applications:

• Shared preferences—Stores private data in key-value pairs • Internal storage—Stores private data in the memory of the device • External storage—Stores data, which can be available to other apps on shared external storage • SQLite database—Stores structured data in a private database • Network connection—Stores data on a web server

Instead, retrieve the SharedPreferences object and use the appropriate method to retrieve a key's value by name:

• getString( )—Retrieves string values • getInt( )—Retrieves integer values • getLong( )—Retrieves long values • getFloat( )—Retrieves float values • getBoolean( )—Retrieves Boolean value

The SharedPreference for this name data is a set of data values: key1 uniquely identifies the preference and intYears represents the actual value of the integer. A preference can be any of a number of different data types. The following data types are supported by the SharedPreferences class:

• putString( )—Stores string values • putInt( )—Stores integer values • putLong( )—Stores long values • putFloat( )—Stores float values • putBoolean( )—Stores Boolean value


Related study sets

Chapter Two: Consumer Issues and Regulations

View Set

History 212 - Chapter 36-38 Quiz

View Set

rock and roll study guide part 1

View Set

CH 32 Assessment of Hematologic Function and Treatment Modalities (E1)

View Set

Personal Finance Ch 2 Financial Aspects of Career Planning

View Set

BUS 5113 Research Methods Chapter 4

View Set

MKT 402 consumer behavior final (WIP) ADD MORE TO IT

View Set

CH.16 PUBLIC HEALTH ENEMY NO.2 AND GROWING: POOR DIET AND PHYSICAL INACTIVITY

View Set

Solids, Liquids, Gases and Gas Laws

View Set