2つのアクティビティで申し込みをしました。最初のアクティビティはユーザーパラメータをインポートし、2番目のアクティビティはBluetooth経由でデータを送信します。.ACTION_REQUEST_ENABLE
ブルートゥースが無効になっている場合は有効にするために使用しますが、btを閉じるとapkが終了します。動作しません。何か助けはありますか?
私はこれを使用します。アクティビティの作成と開始ハンドラーおよび実行可能後のコード...私はそれをfindBTと動作するだけでテストします...
void findBT()
{
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter == null)
{
myLabel.setText("No bluetooth adapter available");
}
if(!mBluetoothAdapter.isEnabled())
{
//My problem is there
Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBluetooth, 0);
}
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if(pairedDevices.size() > 0)
{
for(BluetoothDevice device : pairedDevices)
{
if(device.getName().equals(strValue2))
{
mmDevice = device;
break;
}
}
}
myLabel.setText("Bluetooth Device Found");
}