Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Check if a feature is available in Android

Tags:

android

Quick Question:

Where can I find or check if a certain feature (Bluetooth, NFC, WiFi, GPS, ...) is present in an Android device?

For a simpler example: If the device doesn't have a Bluetooth available (ie: There is no bluetooth). Is there a way to check?

like image 946
Mr A Avatar asked Dec 05 '22 10:12

Mr A


1 Answers

You can use the PackageManager.

The below code checks if there is a camera available.

import android.content.pm.PackageManager;

PackageManager pm = context.getPackageManager();

if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {

}

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

like image 68
Gokul Nath KP Avatar answered Dec 07 '22 00:12

Gokul Nath KP