परिचय
ब्लूटूथ 5.0 ने LE 2M PHY (फिजिकल लेयर) पेश किया जो तेज डेटा दर प्रदान करता है। यह लेख जांचता है कि डिवाइस का ब्लूटूथ एडाप्टर इसका समर्थन करता है या नहीं।
कार्यान्वयन
चरण 1: लेआउट (activity_main.xml)
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="30sp"
android:gravity="center" />चरण 2: MainActivity.java
public class MainActivity extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text);
BluetoothManager manager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
textView.setText("" + manager.getAdapter().isLe2MPhySupported());
}
}
}चरण 3: AndroidManifest.xml में अनुमतियां
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
व्याख्या
- `BluetoothManager` सिस्टम सेवा से प्राप्त करें।
- `getAdapter()` से लोकल एडाप्टर प्राप्त करें।
- API 26 (Android 8.0) और ऊपर `isLe2MPhySupported()` उपलब्ध है।
- विधि बूलियन लौटाती है: true यदि LE 2M PHY सपोर्टेड है।
यह सुविधा ब्लूटूथ लो एनर्जी कनेक्शन में उच्च थ्रूपुट सक्षम करती है।