我有以下启动活动的代码,该代码用于当用户单击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;
}