Check If Your Android Device Back Upward Bluetooth Depression Energy

Posted on

Android 4.3 (API Level 18) introduces built-in platform back upward for Bluetooth Low Energy inwards the key business office too provides APIs that apps tin purpose to uncovering devices, question for services, too read/write characteristics.

To cheque if your device support Bluetooth Low Energy programmically, cheque (getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)).

Nexus 7, 1st gen, non back upward BlueTooth LE!
MK 908III Android mini PC back upward both Bluetooth too Bluetooth LE

package com.example.androidcheckbtle;  import android.support.v7.app.ActionBarActivity; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import android.widget.TextView;  populace flat MainActivity extends ActionBarActivity {   @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.activity_main);      TextView textManufacturer = (TextView)findViewById(R.id.manufacturer);   TextView textModel = (TextView)findViewById(R.id.model);   TextView textSupportBT = (TextView)findViewById(R.id.supportbt);   TextView textSupportBTLE = (TextView)findViewById(R.id.supportbtle);      //Get brand, manufacturer too model of your device   textManufacturer.setText(Build.BRAND + " : " + Build.MANUFACTURER);   textModel.setText(Build.MODEL);      //Check if your device back upward BlueTooth   if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)){    textSupportBT.setText("Support BLUETOOTH");   }else{    textSupportBT.setText("NOT Support BLUETOOTH");   }      //Check if your device back upward Bluetooth Low Energy   if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)){    textSupportBTLE.setText("Support BLUETOOTH_LE");   }else{    textSupportBTLE.setText("NOT Support BLUETOOTH_LE");   }  }  } 

/res/layout/activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     android:orientation="vertical"     tools:context="com.example.androidcheckbtle.MainActivity" >      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />      <TextView         android:id="@+id/manufacturer"         android:layout_width="wrap_content"         android:layout_height="wrap_content"/>     <TextView         android:id="@+id/model"         android:layout_width="wrap_content"         android:layout_height="wrap_content"/>     <TextView         android:id="@+id/supportbt"         android:layout_width="wrap_content"         android:layout_height="wrap_content"/>     <TextView         android:id="@+id/supportbtle"         android:layout_width="wrap_content"         android:layout_height="wrap_content"/>      </LinearLayout>