@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // See ActionBar#setDisplayHomeAsUpEnabled() Intent intent = mSubscriptionInfoHelper.getIntent(FdnSetting.class); intent.setAction(Intent.ACTION_MAIN); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); return true; case MENU_ADD: addContact(); return true; case MENU_EDIT: editSelected(); return true; case MENU_DELETE: deleteSelected(); return true; case MENU_DIAL: dialSelected(); return true; } return super.onOptionsItemSelected(item); }
private void deleteSelected() { if (mCursor.moveToPosition(getSelectedItemPosition())) { String name = mCursor.getString(NAME_COLUMN); String number = mCursor.getString(NUMBER_COLUMN); Intent intent = mSubscriptionInfoHelper.getIntent(DeleteFdnContactScreen.class); intent.putExtra(INTENT_EXTRA_NAME, name); intent.putExtra(INTENT_EXTRA_NUMBER, number); startActivity(intent); } }
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); ActionBar actionBar = getActionBar(); if (actionBar != null) { // android.R.id.home will be triggered in onOptionsItemSelected() actionBar.setDisplayHomeAsUpEnabled(true); } mSubscriptionInfoHelper = new SubscriptionInfoHelper(this, getIntent()); mSubscriptionInfoHelper.setActionBarTitle( getActionBar(), getResources(), R.string.fdn_list_with_label); }
/** Returns the uri for updating the ICC FDN entry, taking into account the subscription id. */ public static Uri getContentUri(SubscriptionInfoHelper subscriptionInfoHelper) { return subscriptionInfoHelper.hasSubId() ? Uri.parse(FDN_CONTENT_PATH_WITH_SUB_ID + subscriptionInfoHelper.getSubId()) : FDN_CONTENT_URI; }
private void addContact() { // If there is no INTENT_EXTRA_NAME provided, EditFdnContactScreen treats it as an "add". Intent intent = mSubscriptionInfoHelper.getIntent(EditFdnContactScreen.class); startActivity(intent); }