diff --git a/docs/html/preview/tv/start/hardware-features.jd b/docs/html/preview/tv/start/hardware-features.jd deleted file mode 100644 index ddec49688ff97..0000000000000 --- a/docs/html/preview/tv/start/hardware-features.jd +++ /dev/null @@ -1,183 +0,0 @@ -page.title=Hardware Features on TV -page.tags="unsupported" - -@jd:body - -
TVs do not have some of the hardware features found on other Android devices. -Touch screens, cameras, and GPS receivers are some of the most commonly used hardware features -which are typically not available on a TV. When you build an app for TV, you must carefully -consider if your app can handle not having these features and, if necessary, work around them.
- -This guide discusses the hardware features not available on TV devices and shows you how to -work around those limitations in your app. For more information on filtering and declaring -features in the manifest, see the -uses-feature guide.
- - -TVs have a different purpose from other devices, and so they do not have hardware -features that other Android-powered devices often have. For this reason, the Android system -does not support the following features for a TV device: - -
| Hardware | -Android feature descriptor | -
|---|---|
| Camera | -android.hardware.camera | -
| GPS | -android.hardware.location.gps | -
| Microphone | -android.hardware.microphone | -
| Near Field Communications (NFC) | -android.hardware.nfc | -
| Telephony | -android.hardware.telephony | -
| Touchscreen | -android.hardware.touchscreen | -
To check if a feature is available at runtime, call {@link - android.content.pm.PackageManager#hasSystemFeature(String)}. This method takes a single string - argument that specifies the feature you want to check. For example, to check for a touch screen, - use {@link android.content.pm.PackageManager#hasSystemFeature(String)} with the argument - {@link android.content.pm.PackageManager#FEATURE_TOUCHSCREEN}.
- -The following code example demonstrates how to detect the availability of a hardware features - at runtime:
- -
-// Check if the telephony hardware feature is available.
-if (getPackageManager().hasSystemFeature("android.hardware.telephony")) {
- Log.d("Mobile Test", "Running on phone");
-// Check if android.hardware.touchscreen feature is available.
-} else if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) {
- Log.d("Tablet Test", "Running on devices that don't support telephony but "+
- "do have a touch screen.");
-} else {
- Log.d("TV Test", "Running on a TV!");
-}
-
-
-- Note: You can also use the {@link android.app.UiModeManager#getCurrentModeType - UiModeManager.getCurrentModeType()} method to detect the current platform type. For TV devices, - this method returns a value of {@link android.content.res.Configuration#UI_MODE_TYPE_TELEVISION - Configuration.UI_MODE_TYPE_TELEVISION}. -
- - -Depending on the design and functionality of your app, you may be able to work around certain - hardware features being unavailable. This section discusses how to work around specific hardware - features.
- - -Android doesn't support touch screen interaction for TV devices, since most TVs don't have touch - screens, and using a touch screen is not consistent with a viewing environment where the user is - seated 10 feet away from the display.
- -On TV devices, you should work around this limitation by supporting navigation using a directional - pad (D-pad) on TV remote control. For more information on properly supporting navigation using - TV-friendly controls, see Navigation for - TV.
- -You can explicitly declare if your application requires (or does not require) a touch screen - by including the following entry in your manifest:
- --<uses-feature android:name="android.hardware.touchscreen" - android:required="false"/> -- - -
Although a TV typically does not have a camera, you can still provide a photography-related - application on a TV. For example, if you have an app that takes, views and edits photos, you can - disable its picture-taking functionality for TVs and still allow users to view and even edit - photos. If you decide that you want to enable your camera-related application to work on a - TV device without a camera, you can add an attribute to your app manifest declaring that - a camera is not required by your app:
- --<uses-feature android:name="android.hardware.camera" android:required="false" /> -- -
If you enable your application to run without a camera, you should add code to your application -that detects if the camera feature is available and makes adjustments to the operation of your app. -The following code example demonstrates how to detect the presence of a camera:
- -
-// Check if the camera hardware feature is available.
-if (getPackageManager().hasSystemFeature("android.hardware.camera")) {
- Log.d("Camera test", "Camera available!");
-} else {
- Log.d("Camera test", "No camera available. View and edit features only.");
-}
-
-
-
-TVs are stationary, indoor devices, and do not have built-in global positioning system (GPS) - receivers. If your application uses location information, you can still allow users to search - for a location, or use a static location provider such as a zip code configured during the - TV device setup.
- -
-LocationManager locationManager = (LocationManager) this.getSystemService(
- Context.LOCATION_SERVICE);
-Location location = locationManager.getLastKnownLocation("static");
-Geocoder geocoder = new Geocoder(this);
-Address address = null;
-
-try {
- address = geocoder.getFromLocation(location.getLatitude(),
- location.getLongitude(), 1).get(0);
- Log.d("Zip code", address.getPostalCode());
-
-} catch (IOException e) {
- Log.e(TAG, "Geocoder error", e);
-}
-
-
diff --git a/docs/html/preview/tv/start/index.jd b/docs/html/preview/tv/start/index.jd
deleted file mode 100644
index 8081995ec825a..0000000000000
--- a/docs/html/preview/tv/start/index.jd
+++ /dev/null
@@ -1,237 +0,0 @@
-page.title=Get Started with TV Apps
-page.tags="leanback","recyclerview","launcher"
-
-@jd:body
-
-This guide describes how to prepare your development environment and projects for building - TV apps, including updating your existing app to run on TV devices.
- -- Important: There are specific requirements your app must meet in order to - qualify as an Android TV app on Google Play. For more information, see the requirements listed - in Publishing TV Apps. -
- - -Before you begin setting up to build apps for TV, you must:
- -TV apps use the same structure as those for phones and tablets. This means you can modify - your existing apps to also run on TV devices or create new apps based on what you already know - about building apps for Android. This section discusses how to modify an existing app, or create a - new one, to run on TV devices.
- -These are the main steps to creating an app that runs on TV devices. Only the first - is required:
- -An application intended to run on TV devices must declare a launcher activity for TV - in its manifest using a {@code android.intent.category.LEANBACK_LAUNCHER} intent filter. - This filter identifies your app as being built for TV, enabling it to be displayed in the - Google Play store app running on TV devices. Declaring this intent also identifies which activity - in your app should be launched when a user selects its icon on the TV home screen.
- -- Caution: If you do not include the {@code LEANBACK_LAUNCHER} intent filter in - your app, it is not visible to users running the Google Play store on TV devices. Also, if your - app does not have this filter when you load it onto a TV device using developer tools, the app - does not appear in the TV user interface. -
- -The following code snippet shows how to include this intent filter in your manifest:
- --<application> - ... - <activity - android:name="com.example.android.MainActivity" - android:label="@string/app_name" > - - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <activity - android:name="com.example.android.TvActivity" - android:label="@string/app_name" - android:theme="@style/Theme.Leanback"> - - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> - </intent-filter> - - </activity> -</application> -- -
The second activity manifest entry in the example above specifies that activity as - the main one when your app launches on an TV device.
- -If you have an existing app that you are modifying for TV use, your app should not use the same - activity layout for TV that it does for phones and tablets. The user interface of your TV app (or - TV portion of your existing app) should provide a simpler interface that can be easily navigated - using a remote control from a couch. For guidelines on designing an app for TV, see the - TV Design guide. For more instructions on - developing a user interface appropriate to TV, see the - TV User Interface guide. -
- - -The Preview SDK includes support libraries that are intended for use with TV apps. These - libraries provide APIs and user interface widgets for use on TV devices. The libraries are - located in the {@code <sdk>/extras/android/support/} directory where you installed the - Preview SDK. Here is a list of the libraries and their general purpose:
- -- Note: You are not required to use these support libraries for your TV app. - However, we strongly recommend using them, particularly for apps that provide a media catalog - browsing interface. -
- -If you decide to use the v17 leanback library for your app, you should note that it is - dependent on the - v4 support library. This means - that apps that use the leanback support library should include all of these support - libraries:
- -The v17 leanback library contain resources, which requires - you to take specific steps to include it in app projects. For instructions on - importing a support library with resources, see - - Support Library Setup. -
- - -After you have completed the steps described above, it's time to start building apps for - the big screen! Check out these additional topics to help you build your app for TV: - -
Running your app is an important part of the development process. The AVD Manager in the - Android SDK provides the device definitions that allows you to create virtual TV devices for - running and testing your applications.
- -To create an virtual TV device:
- -- Note: For best performance of the TV emulator device, enable the Use - Host GPU option and CPU platform image that supports hardware acceleration. For - more information on hardware acceleration of the emulator, see - Using the Emulator. -
-To test your application on the virtual TV device:
- -For more information about using emulators see, -Using the Emulator. For more information about deploying apps to emulators from -Eclipse with ADT, see -Building and Running from Eclipse with ADT.
- diff --git a/docs/html/preview/tv/ui/layouts.jd b/docs/html/preview/tv/ui/layouts.jd deleted file mode 100644 index b9ca7b9935067..0000000000000 --- a/docs/html/preview/tv/ui/layouts.jd +++ /dev/null @@ -1,298 +0,0 @@ -page.title=Layouts for TV - -@jd:body - -- A TV screen is typically viewed from about 10 feet away, and while it is much larger than most - other Android device displays, this type of screen does not provide the same level of precise - detail and color as a smaller device. These factors require that you create app layouts with - TV devices in mind in order to create a useful and enjoyable user experience.
- -This guide provides direction and implementation details for building effective layouts inN - TV apps.
- - -Android Themes can provide a basis for - layouts in your TV apps. You should use a theme to modify the display of your app activities - that are meant to run on a TV device. This section explains which themes you should use.
- - -The Leanback library provides a standard theme for TV activities, called {@code - Theme.Leanback}, which establishes a consistent visual style for TV apps. Use of this theme is - recommended for most apps. This theme is recommended for any TV app that uses the Leanback - library classes. The following code sample shows how to apply this theme to a given - activity within an app:
- --<activity - android:name="com.example.android.TvActivity" - android:label="@string/app_name" - android:theme="@style/Theme.Leanback"> -- - -
The title bar is a standard user interface element for Android apps on phones and tablets, - but it is not appropriate for TV apps. If you are not using the Leanback library classes, - you should apply this theme to your TV activities. The following code example from a TV app - manifest demonstrates how to apply this theme to remove the display of a title bar: -
- --<application> - ... - - <activity - android:name="com.example.android.TvActivity" - android:label="@string/app_name" - android:theme="@android:style/Theme.NoTitleBar"> - ... - - </activity> -</application> -- - -
Layouts for TV devices should follow some basic guidelines to ensure they are usable and - effective on large screens. Follow these tips to build landscape layouts optimized for TV screens: -
- -Layouts for TV have some unique requirements due to the evolution of TV standards and the - desire to always present a full screen picture to viewers. For this reason, TV devices may - clip the outside edge of an app layout in order to ensure that the entire display is filled. - This behavior is generally referred to as Overscan.
- -In order to account for the impact of overscan and make sure that all the user interface - elements you place in a layout are actually shown on screen, you should incorporate a 10% margin - on all sides of your layout. This translates into a 27dp margin on the left and right edges and - a 48dp margin on the top and bottom of your base layouts for activities. The following - example layout demonstrates how to set these margins in the root layout for a TV app: -
- --<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/base_layout" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical" - android:layout_marginTop="27dp" - android:layout_marginLeft="48dp" - android:layout_marginRight="48dp" - android:layout_marginBottom="27dp" > -</LinearLayout> -- -
- Caution: Do not apply overscan margins to your layout if you are using the - Leanback Support Library {@code BrowseFragment} or related widgets, as those layouts already - incorporate overscan-safe margins. -
- - --The text and controls in a TV app layout should be easily visible and navigable from a distance. -Follow these tips to make them easier to see from a distance : -
- --<TextView - android:id="@+id/atext" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:gravity="center_vertical" - android:singleLine="true" - android:textAppearance="?android:attr/textAppearanceMedium"/> --
The common high-definition TV display resolutions are 720p, 1080i, and 1080p. - Your TV layout should target a screen size of 1920 x 1080 pixels, and then allow the Android - system to downscale your layout elements to 720p if necessary. In general, downscaling - (removing pixels) does not degrade your layout presentation quality. However, upscaling can - cause display artifacts that degrade the quality of your layout and have a negative impact on - the user experience of your app.
- -- To get the best scaling results for images, provide them as - 9-patch image elements if possible. If you - provide low quality or small images in your layouts, they will appear pixelated, fuzzy, or - grainy. This is not a good experience for the user. Instead, use high-quality images. -
- -- For more information on optimizing layouts and resources for large screens see - Designing for multiple screens. -
- - -There are a few approaches to building layouts for TV that you should avoid because they do not -work well and lead to bad user experiences. Here are some user interface approaches you -should specifically not use when developing a layout for TV. -
- -For more information on designing layouts that are appropriate to TV, see the - TV Design guide.
- - -TV devices, like any other Android device, have a limited amount of memory. If you build your - app layout with very high-resolution images or use many high-resolution images in the operation - of your app, it can quickly run into memory limits and cause out of memory errors. - To avoid these types of problems, follow these tips:
- -
- // Get the source image's dimensions
- BitmapFactory.Options options = new BitmapFactory.Options();
- // This does not download the actual image, just downloads headers.
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeFile(IMAGE_FILE_URL, options);
- // The actual width of the image.
- int srcWidth = options.outWidth;
- // The actual height of the image.
- int srcHeight = options.outHeight;
-
- // Only scale if the source is bigger than the width of the destination view.
- if(desiredWidth > srcWidth)
- desiredWidth = srcWidth;
-
- // Calculate the correct inSampleSize/scale value. This approach helps reduce
- // memory use. This value should be a power of 2.
- int inSampleSize = 1;
- while(srcWidth / 2 > desiredWidth){
- srcWidth /= 2;
- srcHeight /= 2;
- inSampleSize *= 2;
- }
-
- float desiredScale = (float) desiredWidth / srcWidth;
-
- // Decode with inSampleSize
- options.inJustDecodeBounds = false;
- options.inDither = false;
- options.inSampleSize = inSampleSize;
- options.inScaled = false;
- // Ensures the image stays as a 32-bit ARGB_8888 image.
- // This preserves image quality.
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-
- Bitmap sampledSrcBitmap = BitmapFactory.decodeFile(IMAGE_FILE_URL, options);
-
- // Resize
- Matrix matrix = new Matrix();
- matrix.postScale(desiredScale, desiredScale);
- Bitmap scaledBitmap = Bitmap.createBitmap(sampledSrcBitmap, 0, 0,
- sampledSrcBitmap.getWidth(), sampledSrcBitmap.getHeight(), matrix, true);
- sampledSrcBitmap = null;
-
- // Save
- FileOutputStream out = new FileOutputStream(LOCAL_PATH_TO_STORE_IMAGE);
- scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
- scaledBitmap = null;
-
- TV devices provide a limited set of navigation controls for apps. Creating an effective - navigation scheme for your TV app depends on understanding these limited controls and the limits - of users' perception while operating your app. As you build your Android app for TVs, - you should pay special attention to how the user actually navigates around your app - when using remote control buttons instead of a touch screen.
- -This guide shows you how to build an effective navigation scheme for your TV app.
- - -On a TV device, users navigate with controls on a remote control device, using either a - directional pad (D-pad) or arrow keys. This type of control limits movement to up, down, left, - and right. To build a great TV-optimized app, you must provide a navigation scheme where - the user can quickly learn how to navigate your app using these limited controls.
- -Follow these guidelines to build a navigation system that works well with a D-pad on a TV device: -
- -The Android framework handles directional navigation between layout elements automatically, so - you typically do not need to do anything extra for your app. However, you should thoroughly test - navigation with a D-pad control to discover any navigation problems. If you discover that your - screen layout makes navigation difficult, or if you want users to move through the layout in a - specific way, you can set up explicit directional navigation for your controls. The following - code sample shows how to define the next control to receive focus for a - {@link android.widget.TextView} layout object:
- --<TextView android:id="@+id/Category1" - android:nextFocusDown="@+id/Category2"\> -- -
The following table lists all of the available navigation attributes for Android user interface -widgets:
- -| Attribute | -Function | -
|---|---|
| {@link android.R.attr#nextFocusDown} | -Defines the next view to receive focus when the user navigates down. | -
| {@link android.R.attr#nextFocusLeft} | -Defines the next view to receive focus when the user navigates left. | -
| {@link android.R.attr#nextFocusRight} | -Defines the next view to receive focus when the user navigates right. | -
| {@link android.R.attr#nextFocusUp} | -Defines the next view to receive focus when the user navigates up. | -
To use one of these explicit navigation attributes, set the value to the ID ({@code android:id} - value) of another widget in the layout. You should set up the navigation order as a loop, so that - the last control directs focus back to the first one.
- -- Note: You should only use these attributes to modify the navigation order if the - default order that the system applies does not work well. -
- - -The success of a navigation scheme on TV devices is strongly dependent on how easy it is for a - user to determine what user interface element is in focus on screen. If you do not provide clear - indications of what is in focus on screen (and therefore what item they can take action on), - users can quickly become frustrated and exit your app. By the same token, it is important - to always have an item in focus that a user can take action on immediately after your app starts, - and any time your app is not playing content.
- -Your app layout and implementation should use color, size, animation, or a combination of - these attributes to help users easily determine what actions they can take next. Use a uniform - scheme for indicating focus across your application.
- -Android provides -Drawable State List Resources to implement highlights for selected and focused controls. The -following code example demonstrates how to indicate selection of a button object: -
- --<!-- res/drawable/button.xml --> -<?xml version="1.0" encoding="utf-8"?> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_pressed="true" - android:drawable="@drawable/button_pressed" /> <!-- pressed --> - <item android:state_focused="true" - android:drawable="@drawable/button_focused" /> <!-- focused --> - <item android:state_hovered="true" - android:drawable="@drawable/button_focused" /> <!-- hovered --> - <item android:drawable="@drawable/button_normal" /> <!-- default --> -</selector> -- -
-This layout XML applies the above state list drawable to a {@link android.widget.Button}: -
--<Button - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:background="@drawable/button" /> -- -
Make sure to provide sufficient padding within the focusable and selectable controls so that - the highlights around them are clearly visible.
- diff --git a/docs/html/training/training_toc.cs b/docs/html/training/training_toc.cs index 5443c56d326d8..bb00f80777731 100644 --- a/docs/html/training/training_toc.cs +++ b/docs/html/training/training_toc.cs @@ -839,6 +839,48 @@ include the action bar on devices running Android 2.1 or higher." + +