アクティビティを開始する次のコードがあります。このコードは、ユーザーがAndroidデバイスの[メニュー]ボタンをクリックすると表示されるサブメニュー用です。問題は、ボタンをクリックすると新しいアクティビティが開始され、以前のアクティビティが失われることです。ブルートゥース接続を形成しました!
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent serverIntent = null;
Intent PassIntent;
Intent PassIntent1;
switch (item.getItemId()) {
/*case R.id.home:
// Launch the DeviceListActivity to see devices and do scan
serverIntent = new Intent(this, engineStarter.class);
startActivity(serverIntent);
return true;*/
/*case R.id.insecure_connect_scan:
// Launch the DeviceListActivity to see devices and do scan
serverIntent = new Intent(this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_INSECURE);
return true;*/
/*case R.id.discoverable:
// Ensure this device is discoverable by others
ensureDiscoverable();
return true;*/
case R.id.setpassword:
PassIntent = new Intent(this, SetPassword.class);
startActivity(PassIntent);
return true;
case R.id.home:
// Launch the DeviceListActivity to see devices and do scan
serverIntent = new Intent(this, engineStarter.class);
startActivity(serverIntent);
return true;
}
return false;
}