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

How to Determine if Android Device has Proximity Sensor

public static final String FEATURE_SENSOR_PROXIMITY was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device includes a proximity sensor.
Constant Value: "android.hardware.sensor.proximity"


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolProximitySupported. 

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

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

bolProximitySupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY);
if (bolProximitySupported) {
Toast.makeText(this, "Device has a Proximity Sensor", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Device does NOT have a Proximity Sensor!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device has a Light Sensor, using PackageManager

public static final String FEATURE_SENSOR_LIGHT was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device includes a light sensor.
Constant Value: "android.hardware.sensor.light"
* For API Level 3 and above, you may also use How to Determine if Android Device has Light Sensor, using SensorManager


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolLightSupported. 

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

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

bolLightSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_LIGHT);
if (bolLightSupported) {
Toast.makeText(this, "Device has a Light Sensor", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Device does NOT have a Light Sensor!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device Supports Live Wallpapers

public static final String FEATURE_LIVE_WALLPAPER was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device supports live wallpapers.
Constant Value: "android.software.live_wallpaper"

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolLWSupported. 

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

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

bolLWSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_LIVE_WALLPAPER);
if (bolLWSupported) {
Toast.makeText(this, "Device supports live wallpapers", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No live wallpapers support!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device Camera Supports Flash

public static final String FEATURE_CAMERA_FLASH was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device's camera supports flash.
Constant Value: "android.hardware.camera.flash"

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolCameraFlashSupported. 

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

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

bolCameraFlashSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
if (bolCameraFlashSupported) {
Toast.makeText(this, "Device has Camera Flash ability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Camera Flash ability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device has Camera Autofocus Feature

public static final String FEATURE_CAMERA_AUTOFOCUS was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device's camera supports auto-focus.
Constant Value: "android.hardware.camera.autofocus"

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolCameraAutoSupported. 

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

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

bolCameraAutoSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS);
if (bolCameraAutoSupported) {
Toast.makeText(this, "Device has Camera Autofocus ability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Camera Autofocus ability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device has Proximity Sensor Feature

public static final String FEATURE_SENSOR_PROXIMITY was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device includes a proximity sensor.
Constant Value: "android.hardware.sensor.proximity"


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolProximitySupported. 

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

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

bolProximitySupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY);
if (bolProximitySupported) {
Toast.makeText(this, "Device has Proximity Sensor capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Proximity Sensor capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

Resources:
- http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_SENSOR_PROXIMITY
- http://developer.android.com/guide/topics/sensors/sensors_position.html

How to Determine if Android Device has Touch Screen Multi-Touch Feature

public static final String FEATURE_TOUCHSCREEN_MULTITOUCH was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String)
 The device's touch screen supports multitouch sufficient for basic two-finger gesture detection.
Constant Value: "android.hardware.touchscreen.multitouch"
Some examples of Touch Screen Multi-Touch Android Tablets and Touch Screen Multi-Touch Android Phones.


1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolTSMSupported. 

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

4. In the onCreate method, add the below code. This will return the touch screen multi-touch ability to a boolean named bolTSMSupported. It will then display a toast displaying the touch screen multi-touch ability of the device to the user.

bolTSMSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH);
if (bolTSMSupported) {
Toast.makeText(this, "Device has Touch Screen Multi-Touch capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Touch Screen Multi-Touch capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

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

How to Determine if Android Device has GSM Telephony

public static final String FEATURE_TELEPHONY_GSM was added in API level 7
The device has a GSM telephony stack.
Constant Value: "android.hardware.telephony.gsm"
GSM (Global System for Mobiles)
AT&T and T-Mobile use GSM. Most of the U.S. uses CDMA. Most of the world uses GSM. GSM Phones use removable SIM cards. You can buy unlocked GSM phones and just swap the SIM cards.

1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolGSMSupported. 

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

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

bolGSMSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_GSM);
if (bolGSMSupported) {
Toast.makeText(this, "Device has GSM Telephony capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No GSM Telephony capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

How to Determine if Android Device has CDMA Telephony Capabilities

public static final String FEATURE_TELEPHONY_CDMA was added in API level 7
The device has a CDMA telephony stack.
Constant Value: "android.hardware.telephony.cdma"
CDMA stands for Code Division Multiple Access.
In the U.S., Sprint, Verizon and U.S. Cellular use CDMA. Most of the U.S. uses CDMA. Most of the world uses GSM. CDMA Phones do NOT use a SIM card.
There is no such thing as an unlocked phone on a CDMA phone.
If the phone used 4G LTE, it may have a SIM card, as it is required for 4G LTE.

1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolCDMASupported. 

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

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

bolCDMASupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA);
if (bolCDMASupported) {
Toast.makeText(this, "Device has CDMA Telephony capability", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No CDMA Telephony capability!", Toast.LENGTH_LONG).show();
}

5. Compile and run!

How to Determine if Android Device has Telephony Support

public static final String FEATURE_TELEPHONY was added in API level 7
The device has a telephony radio with data communication support.
Constant Value: "android.hardware.telephony"

1. Get a PackageManager Instance named myPackageManager.

2. Create a Boolean Variable named bolTelephonySupported. 


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

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

5. Compile and run!

How to Determine if Camera(facing away from screen) exists on an Android Device

public static final String FEATURE_CAMERA was added in API level 7
Feature for getSystemAvailableFeatures() and hasSystemFeature(String).
The device has a camera facing away from the screen.
Constant Value: "android.hardware.camera"

1. Get a PackageManager Instance and save to myPackageManager.

2. Create a Boolean Variable named bolCameraSupported. 

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

4. In the onCreate method, add the below code. This will return the camera support to a boolean named bolCameraSupported. It will then display a toast displaying the camera existence on the device to the user.

bolCameraSupported = myPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA);
if (bolCameraSupported) {
Toast.makeText(this, "Device has a Camera", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "No Camera on Device!", Toast.LENGTH_LONG).show();
}