コード例 #1
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       // This ID represents the Home or Up button. In the case of this
       // activity, the Up button is shown. Use NavUtils to allow users
       // to navigate up one level in the application structure. For
       // more details, see the Navigation pattern on Android Design:
       //
       // http://developer.android.com/design/patterns/navigation.html#up-vs-back
       //
       Intent upIntent = NavUtils.getParentActivityIntent(this);
       upIntent.putExtra(SingleUnitActivity.EXTRA_DEVICE_ID, mDeviceId);
       upIntent.putExtra(SingleUnitActivity.EXTRA_HARDWARE_UNIT_ID, mHardwareUnit.getId());
       NavUtils.navigateUpTo(this, upIntent);
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
コード例 #2
0
 public void startDeviceDetailsActivity() {
   Intent intent = new Intent(this, DeviceDetailsActivity.class);
   intent.putExtra(SingleUnitActivity.EXTRA_DEVICE_ID, mDeviceId);
   intent.putExtra(SingleUnitActivity.EXTRA_HARDWARE_UNIT_ID, mHardwareUnit.getId());
   startActivity(intent);
 }