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

How to Determine if Android Device has a Step Detector

public static final String FEATURE_SENSOR_STEP_DETECTOR was added in API level 19
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device includes a hardware step detector.
Constant Value: "android.hardware.sensor.stepdetector"


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolStepDetectorSupported. 

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

4. In the onCreate method, add the below code. This will return the step detector sensor availability to a boolean named bolStepDetectorSupported. It will then display a toast displaying the step detector sensor availability of the device to the user.

bolStepDetectorSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_DETECTOR);
if (bolStepDetectorSupported) {
Toast.makeText(this, "Device has a Step Detector Sensor", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Device does NOT have a Step Detector Sensor!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device has a Step Counter

public static final String FEATURE_SENSOR_STEP_COUNTER was added in API level 19
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device includes a hardware step counter.
Constant Value: "android.hardware.sensor.stepcounter"


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolStepCounterSupported. 

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

4. In the onCreate method, add the below code. This will return the step counter sensor availability to a boolean named bolStepCounterSupported. It will then display a toast displaying the step counter sensor availability of the device to the user.

bolStepCounterSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_COUNTER);
if (bolStepCounterSupported) {
Toast.makeText(this, "Device has a Step Counter Sensor", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Device does NOT have a Step Counter Sensor!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device Supports Host-Based NFC Card Emulation

public static final String FEATURE_NFC_HOST_CARD_EMULATION was added in API level 19
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device supports host- based NFC card emulation.
Constant Value: "android.hardware.nfc.hce"


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolHCNFCSupported. 

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

4. In the onCreate method, add the below code. This will return the host-based NFC ability to a boolean named bolHCNFCSupported. It will then display a toast displaying the host-based NFC ability of the device to the user.

bolHCNFCSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION);
if (bolHCNFCSupported) {
Toast.makeText(this, "Device has host-based NFC capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No host-based NFC capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

Other Resources:
- Professional NFC Application Development for Android by Vedat Coskun

How to Determine if Android Device has Policy Enforcement Feature

public static final String FEATURE_DEVICE_ADMIN was added in API level 19
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device supports device policy enforcement via device admins.
Constant Value: "android.software.device_admin"

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolPESupported. 

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

4. In the onCreate method, add the below code. This will return the policy enforcement ability to a boolean named bolPESupported. It will then display a toast displaying the policy enforcement ability on the device to the user.

bolPESupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN);
if (bolPESupported) {
Toast.makeText(this, "Device has Policy Enforcement Capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Policy Enforcement capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device has IR Capability

public static final String FEATURE_CONSUMER_IR was added in API level 19
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device is capable of communicating with consumer IR devices.
Constant Value: "android.hardware.consumerir"
Here are some examples of Android Cell Phones with Infrared. 

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolIRSupported. 

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

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

bolIRSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_CONSUMER_IR);
if (bolIRSupported) {
Toast.makeText(this, "Device has IR Capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No IR capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

android:accessibilityLiveRegion

Added in API Level 19

Indicates to accessibility services whether the user should be notified when this view changes. May be an integer value, such as "100".

       android:accessibilityLiveRegion = "none"
       android:accessibilityLiveRegion = "polite"
       android:accessibilityLiveRegion = "assertive"
  />

none - Accessibility services should not announce changes to this view.
polite - Accessibility services should announce changes to this view.
assertive - Accessibility services should interrupt ongoing speech to immediately announce changes to this view.

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