package:
import package:
import android.bluetooth.*;
<uses-permission android:name="android.permission.BLUETOOTH"/>
for more advanced bluetooth tasks , like setting name, connecting....
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
ACCESS THE BLUETOOTH ADAPTER
Android bluetooth apis include bluetooth adapter class.
if we want to perform any action
BluetoothAdapter class must be instantiated.
BluetoothAdapter bluetooth=BluetoothAdapter.getDefaultAdapter();
if(bluetooth!=null)
{
// work with bluetooth
}
else
{
//disabled// switch on bluetooth
}
for displaying name of bluetooth
String status;
if(bluetooth.isEnabled)
{
String mydeviceaddress=bluetooth.getAddress();
String mydevicename=bluetooth.getName();
status=mydeviceaddress+:+mydevicename;
}
else
{
status="bluetooth is not enabled"
}
}
setting name
bluetooth.setName("Mydevice");
0 coment�rios:
Post a Comment