Beispiel #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        /* This is called when the Home (Up) button is pressed
         * in the Action Bar. http://goo.gl/lJxjA */
        Intent upIntent = new Intent(this, MainActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
          TaskStackBuilder.from(this).addNextIntent(upIntent).startActivities();
          finish();
        } else {
          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;

      case R.id.menu_preferences:
        Intent preferencesActivity = new Intent(getBaseContext(), SettingsActivity.class);
        startActivity(preferencesActivity);
        return true;

      case R.id.menu_upload:
        if (Constants.PRO_VERSION) {
          Intent localPhotosActivity = new Intent(getBaseContext(), LocalPhotosActivity.class);
          startActivity(localPhotosActivity);
        } else {
          BuyProDialog.show(this);
        }
        return true;

      case R.id.menu_about:
        new AboutDialogFragment().show(getSupportFragmentManager(), "AboutDialogFragment");
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       // This is called when the Home (Up) button is pressed in the action bar.
       // Create a simple intent that starts the hierarchical parent activity and
       // use NavUtils in the Support Package to ensure proper handling of Up.
       Intent upIntent = new Intent(this, MainActivity.class);
       if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
         // This activity is not part of the application's task, so create a new task
         // with a synthesized back stack.
         TaskStackBuilder.from(this)
             // If there are ancestor activities, they should be added here.
             .addNextIntent(upIntent)
             .startActivities();
         finish();
       } else {
         // This activity is part of the application's task, so simply
         // navigate up to the hierarchical parent activity.
         NavUtils.navigateUpTo(this, upIntent);
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case android.R.id.home:
        Intent upIntent = new Intent(this, MainActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {

          TaskStackBuilder.from(this).addNextIntent(upIntent).startActivities();

          finish();
        } else {

          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // TODO Auto-generated method stub
   switch (item.getItemId()) {
     case android.R.id.home:
       Intent upIntent = new Intent(this, MainActivity.class);
       if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
         TaskStackBuilder.from(this)
             // 如果这里有很多原始的Activity,它们应该被添加在这里
             .addNextIntent(upIntent)
             .startActivities();
         finish();
       } else {
         NavUtils.navigateUpTo(this, upIntent);
       }
       break;
   }
   return super.onOptionsItemSelected(item);
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection

    switch (item.getItemId()) {
      case android.R.id.home:
        Intent upIntent = new Intent(this, AChatActivity.class);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
          TaskStackBuilder.from(this).addNextIntent(upIntent).startActivities();
          finish();
        } else {
          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;

      case R.id.action_refresh:
        mXwalkView.load(url, null);
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }