Showing posts with label API Level 16. Show all posts
Showing posts with label API Level 16. Show all posts

How to Determine if Android Device has Television Feature

public static final String FEATURE_TELEVISION was added in API level 16
Feature for getSystemAvailableFeatures() and hasSystemFeature(String): This is a device dedicated to showing UI on a television. Television here is defined to be a typical living room television experience: displayed on a big screen, where the user is sitting far away from it, and the dominant form of input will be something like a DPAD, not through touch or mouse.
Constant Value: "android.hardware.type.television"

1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolTVSupported. 

3. Set the Minimum and Target SDK version  to 16 or greater. 

4. In the onCreate method, add the below code. This will return the television ability to a boolean named bolTVSupported. It will then display a toast displaying the television ability of the device to the user.

bolTVSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION);
if (bolTVSupported) {
Toast.makeText(this, "Device has Television capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Television capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

android:importantForAccessibility

added in API Level 16

Controls how this View is important for accessibility which is if it fire accessibility events and if it is report to accessibility services that query the screen.

1. Ensure to change the minSDKVersion to 16, or greater.

       android:importantForAccessibility = "auto"
       android:importantForAccessibility = "yes"
       android:importantForAccessibility = "no"
       android:importantForAccessibility = "noHideDescendants"

auto - The system determines whether the view is important for accessibility  - default (recommended).
yes - The view is important for accessibility.
no - The view is NOT important for accessibility.
noHideDescendants - The view is NOT important for accessibility, nor are any of its descendant views.

Resources:
http://developer.android.com/reference/android/view/View.html#attr_android:importantForAccessibility
http://developer.android.com/reference/android/R.attr.html#importantForAccessibility

android:fontFamily - Change the FontFamily in a TextView

How to Change the FontFamily in a TextView

android:fontFamily added in API Level 16

1. Add a TextView to your activity. 

2. Ensure your minSdkVersion is 16, or greater.

3. In the main.xml file, add the below line

<TextView
    ....
    android:fontFamily = "sans-serif"
/>

4. To make other fonts

android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)

5. Compile and run!