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

How to Determine if Android Device Supports Adding New Input Methods

public static final String FEATURE_INPUT_METHODS was added in API level 18
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device supports adding new input methods implemented with the InputMethodService API.
Constant Value: "android.software.input_methods"

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolInputSupported

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

4. In the onCreate method, add the below code. This will return the new input method support ability to a boolean named bolInputSupported. It will then display a toast displaying the new input method support ability on the device to the user.

bolInputSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_HOME_SCREEN);
if (bolInputSupported) {
Toast.makeText(this, "Device has new input method support ability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No new input method support ability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_INPUT_METHODS

How to Determine if Android Device has Home Screen Replaceability

public static final String FEATURE_HOME_SCREEN was added in API level 18
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device supports a home screen that is replaceable by third party applications.
Constant Value: "android.software.home_screen"

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolHSSupported

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

4. In the onCreate method, add the below code. This will return the home screen replaceable ability to a boolean named bolHSSupported. It will then display a toast displaying the home screen replaceable ability on the device to the user.

bolHSSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_HOME_SCREEN);
if (bolHSSupported) {
Toast.makeText(this, "Device has home screen replaceable ability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No home screen replaceable ability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_HOME_SCREEN

How to Determine if Android Device Support Bluetooth Low Energy

public static final String FEATURE_BLUETOOTH_LE was added in API level 18
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device is capable of communicating with other devices via Bluetooth Low Energy radio.
Constant Value: "android.hardware.bluetooth_le"
Here are some examples of some Bluetooth Low-Energy Android Devices.


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolBLESupported

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

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

bolBLESupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);
if (bolBLESupported) {
Toast.makeText(this, "Device has Bluetooth Low Energy capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Bluetooth Low Energy capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_BLUETOOTH_LE

How to Determine if Android Device Supports App Widgets

public static final String FEATURE_APP_WIDGETS was added in API level 18
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device supports app widgets.
Constant Value: "android.software.app_widgets"


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolWidgetSupported

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

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

bolWidgetSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS);
if (bolWidgetSupported) {
Toast.makeText(this, "Device supports App Widgets", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Device does NOT support App Widgets!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

Resources:
http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_APP_WIDGETS