Example usage for android.provider Settings ACTION_SYNC_SETTINGS

List of usage examples for android.provider Settings ACTION_SYNC_SETTINGS

Introduction

In this page you can find the example usage for android.provider Settings ACTION_SYNC_SETTINGS.

Prototype

String ACTION_SYNC_SETTINGS

To view the source code for android.provider Settings ACTION_SYNC_SETTINGS.

Click Source Link

Document

Activity Action: Show settings to allow configuration of sync settings.

Usage

From source file:com.btmura.android.reddit.app.ContentBrowserActivity.java

private void handleSyncSettings() {
    Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
    intent.putExtra(Settings.EXTRA_AUTHORITIES, AUTHORITIES);
    startActivity(intent);
}

From source file:org.mozilla.gecko.sync.setup.activities.SetupSyncActivity.java

public void finishResume(Account[] accts) {
    Logger.debug(LOG_TAG, "Finishing Resume after fetching accounts.");
    if (accts.length == 0) { // Start J-PAKE for pairing if no accounts present.
        Logger.debug(LOG_TAG, "No accounts; starting J-PAKE receiver.");
        displayReceiveNoPin();//from   w w  w .  ja  v  a2  s. c o m
        if (jClient != null) {
            // Mark previous J-PAKE as finished. Don't bother propagating back up to this Activity.
            jClient.finished = true;
        }
        jClient = new JPakeClient(this);
        jClient.receiveNoPin();
        return;
    }

    // Set layout based on starting Intent.
    Bundle extras = this.getIntent().getExtras();
    if (extras != null) {
        Logger.debug(LOG_TAG, "SetupSync with extras.");
        boolean isSetup = extras.getBoolean(Constants.INTENT_EXTRA_IS_SETUP);
        if (!isSetup) {
            Logger.debug(LOG_TAG, "Account exists; Pair a Device started.");
            pairWithPin = true;
            displayPairWithPin();
            return;
        }
    }

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Logger.debug(LOG_TAG, "Only one account supported. Redirecting.");
            // Display toast for "Only one account supported."
            // Redirect to account management.
            Toast toast = Toast.makeText(mContext, R.string.sync_notification_oneaccount, Toast.LENGTH_LONG);
            toast.show();

            Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
            intent.setFlags(Constants.FLAG_ACTIVITY_REORDER_TO_FRONT_NO_ANIMATION);
            startActivity(intent);

            finish();
        }
    });
}

From source file:com.phonegap.plugins.nativesettings.NativeSettings.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    PluginResult.Status status = PluginResult.Status.OK;
    Uri packageUri = Uri.parse("package:" + this.cordova.getActivity().getPackageName());
    String result = "";

    //Information on settings can be found here:
    //http://developer.android.com/reference/android/provider/Settings.html

    action = args.getString(0);/*from  www .  ja  v  a 2 s. com*/
    Intent intent = null;

    if (action.equals("accessibility")) {
        intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
    } else if (action.equals("account")) {
        intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
    } else if (action.equals("airplane_mode")) {
        intent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS);
    } else if (action.equals("apn")) {
        intent = new Intent(android.provider.Settings.ACTION_APN_SETTINGS);
    } else if (action.equals("application_details")) {
        intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageUri);
    } else if (action.equals("application_development")) {
        intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
    } else if (action.equals("application")) {
        intent = new Intent(android.provider.Settings.ACTION_APPLICATION_SETTINGS);
    }
    //else if (action.equals("battery_saver")) {
    //    intent = new Intent(android.provider.Settings.ACTION_BATTERY_SAVER_SETTINGS);
    //}
    else if (action.equals("bluetooth")) {
        intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
    } else if (action.equals("captioning")) {
        intent = new Intent(android.provider.Settings.ACTION_CAPTIONING_SETTINGS);
    } else if (action.equals("cast")) {
        intent = new Intent(android.provider.Settings.ACTION_CAST_SETTINGS);
    } else if (action.equals("data_roaming")) {
        intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
    } else if (action.equals("date")) {
        intent = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS);
    } else if (action.equals("about")) {
        intent = new Intent(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS);
    } else if (action.equals("display")) {
        intent = new Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS);
    } else if (action.equals("dream")) {
        intent = new Intent(android.provider.Settings.ACTION_DREAM_SETTINGS);
    } else if (action.equals("home")) {
        intent = new Intent(android.provider.Settings.ACTION_HOME_SETTINGS);
    } else if (action.equals("keyboard")) {
        intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS);
    } else if (action.equals("keyboard_subtype")) {
        intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
    } else if (action.equals("storage")) {
        intent = new Intent(android.provider.Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
    } else if (action.equals("locale")) {
        intent = new Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS);
    } else if (action.equals("location")) {
        intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    } else if (action.equals("manage_all_applications")) {
        intent = new Intent(android.provider.Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
    } else if (action.equals("manage_applications")) {
        intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
    } else if (action.equals("memory_card")) {
        intent = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS);
    } else if (action.equals("network")) {
        intent = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
    } else if (action.equals("nfcsharing")) {
        intent = new Intent(android.provider.Settings.ACTION_NFCSHARING_SETTINGS);
    } else if (action.equals("nfc_payment")) {
        intent = new Intent(android.provider.Settings.ACTION_NFC_PAYMENT_SETTINGS);
    } else if (action.equals("nfc_settings")) {
        intent = new Intent(android.provider.Settings.ACTION_NFC_SETTINGS);
    }
    //else if (action.equals("notification_listner")) {
    //    intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
    //}
    else if (action.equals("print")) {
        intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS);
    } else if (action.equals("privacy")) {
        intent = new Intent(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
    } else if (action.equals("quick_launch")) {
        intent = new Intent(android.provider.Settings.ACTION_QUICK_LAUNCH_SETTINGS);
    } else if (action.equals("search")) {
        intent = new Intent(android.provider.Settings.ACTION_SEARCH_SETTINGS);
    } else if (action.equals("security")) {
        intent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS);
    } else if (action.equals("settings")) {
        intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
    } else if (action.equals("show_regulatory_info")) {
        intent = new Intent(android.provider.Settings.ACTION_SHOW_REGULATORY_INFO);
    } else if (action.equals("sound")) {
        intent = new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS);
    } else if (action.equals("store")) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=" + this.cordova.getActivity().getPackageName()));
    } else if (action.equals("sync")) {
        intent = new Intent(android.provider.Settings.ACTION_SYNC_SETTINGS);
    } else if (action.equals("usage")) {
        intent = new Intent(android.provider.Settings.ACTION_USAGE_ACCESS_SETTINGS);
    } else if (action.equals("user_dictionary")) {
        intent = new Intent(android.provider.Settings.ACTION_USER_DICTIONARY_SETTINGS);
    } else if (action.equals("voice_input")) {
        intent = new Intent(android.provider.Settings.ACTION_VOICE_INPUT_SETTINGS);
    } else if (action.equals("wifi_ip")) {
        intent = new Intent(android.provider.Settings.ACTION_WIFI_IP_SETTINGS);
    } else if (action.equals("wifi")) {
        intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
    } else if (action.equals("wireless")) {
        intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
    } else {
        status = PluginResult.Status.INVALID_ACTION;
        callbackContext.sendPluginResult(new PluginResult(status, result));
        return false;
    }

    if (args.length() > 1 && args.getBoolean(1)) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    }
    this.cordova.getActivity().startActivity(intent);

    callbackContext.sendPluginResult(new PluginResult(status, result));
    return true;
}

From source file:com.jaspersoft.android.jaspermobile.ui.view.activity.NavigationActivity.java

private void handleNavigationAction(int viewId) {
    switch (viewId) {
    case R.id.vg_library:
        currentSelection = R.id.vg_library;
        commitContent(LibraryPageFragment_.builder().build());
        break;//from  ww  w  .j  a  v a 2 s. c  om
    case R.id.vg_repository:
        currentSelection = R.id.vg_repository;
        commitContent(RepositoryPageFragment_.builder().build());
        break;
    case R.id.vg_recent:
        currentSelection = R.id.vg_recent;
        commitContent(RecentPageFragment_.builder().build());
        break;
    case R.id.vg_saved_items:
        currentSelection = R.id.vg_saved_items;
        commitContent(SavedReportsFragment_.builder().build());
        break;
    case R.id.vg_favorites:
        currentSelection = R.id.vg_favorites;
        commitContent(FavoritesPageFragment_.builder().build());
        break;
    case R.id.vg_jobs:
        currentSelection = R.id.vg_jobs;
        commitContent(JobFragmentPresenter_.builder().build());
        break;
    case R.id.vg_add_account:
        startActivityForResult(new Intent(this, AuthenticatorActivity.class), NEW_ACCOUNT);
        break;
    case R.id.vg_manage_accounts:
        String[] authorities = { getString(R.string.jasper_account_authority) };
        Intent manageAccIntent = new Intent(Settings.ACTION_SYNC_SETTINGS);
        manageAccIntent.putExtra(Settings.EXTRA_AUTHORITIES, authorities);
        try {
            startActivity(manageAccIntent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, getString(R.string.wrong_action), Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.tv_settings:
        SettingsActivity_.intent(this).start();
        break;
    case R.id.tv_feedback:
        sendFeedback();
        break;
    case R.id.tv_about:
        AboutDialogFragment.createBuilder(this, getSupportFragmentManager()).show();
    }
}

From source file:com.nuvolect.securesuite.main.SharedMenu.java

/**
 * Process a menu command and return a post command to be executed in the
 * calling activity/*from  ww  w.j a v a2s. co m*/
 * @return post command.
 */
private static POST_CMD process() {

    switch (m_item_id) {

    case R.id.menu_shared_search: {
        SearchDialog.manageSearch(m_act, new SearchDialog.SearchCallbacks() {
            @Override
            public void onContactSelected(long contact_id) {

                if (invalidContact(contact_id)) {
                    Toast.makeText(m_act, "Invalid contact", Toast.LENGTH_SHORT).show();
                    return;
                }

                LogUtil.log("SharedMenu.shared_search id selected: " + contact_id);
                Persist.setCurrentContactId(m_act, contact_id);
                if (m_post_cmd_callbacks == null) {

                    LogUtil.log("ERROR SharedMenu.shared_search callbacks null ");
                } else {

                    m_post_cmd_callbacks.postCommand(POST_CMD.START_CONTACT_DETAIL);
                }
            }
        });
        break;
    }
    case R.id.menu_add_contact: {
        m_contact_id = SqlCipher.createEmptyContact(m_act, Cryp.getCurrentGroup());
        Persist.setCurrentContactId(m_act, m_contact_id);

        // In case the user discards contact, it will be deleted
        Persist.setEmptyContactId(m_act, m_contact_id);
        return POST_CMD.START_CONTACT_EDIT;
    }
    case R.id.menu_delete_contact: {
        if (invalidContact(m_contact_id)) {
            Toast.makeText(m_act, "Select a contact to delete", Toast.LENGTH_SHORT).show();
            return POST_CMD.DONE;
        } else {
            long nextId = 0;
            if (m_cursor != null)
                nextId = SqlCipher.getNextContactId(m_cursor);

            boolean success;
            if (MyGroups.isInTrash(m_contact_id)) {

                success = 1 == SqlCipher.deleteContact(m_act, m_contact_id, true);//sync==true
                if (success)
                    Toast.makeText(m_act, "Contact deleted", Toast.LENGTH_SHORT).show();
            } else {

                success = MyGroups.trashContact(m_act, Cryp.getCurrentAccount(), m_contact_id);
                if (success)
                    Toast.makeText(m_act, "Item moved to trash", Toast.LENGTH_SHORT).show();
            }
            if (!success)
                LogUtil.log("SharedMenu.delete_contact delete failure: " + m_contact_id);

            MyContacts.setValidId(m_act, nextId);

            MyGroups.loadGroupMemory();
            return POST_CMD.REFRESH_LEFT_DEFAULT_RIGHT;
        }
    }
    case R.id.menu_edit_contact: {
        if (invalidContact(m_contact_id)) {
            Toast.makeText(m_act, "Invalid contact", Toast.LENGTH_SHORT).show();
            return POST_CMD.NIL;
        } else
            return POST_CMD.START_CONTACT_EDIT;
    }
    case R.id.menu_edit_save:
    case R.id.menu_edit_discard: {
        return POST_CMD.START_CONTACT_DETAIL;
    }
    case R.id.menu_share_contact: {
        if (invalidContact(m_contact_id)) {
            Toast.makeText(m_act, "Invalid contact", Toast.LENGTH_SHORT).show();
            return POST_CMD.NIL;
        }
        ExportVcf.emailVcf(m_act, Persist.getCurrentContactId(m_act));
        return POST_CMD.NIL;
    }
    case R.id.menu_set_profile:
        Persist.setProfileId(m_act, m_contact_id);
        Toast.makeText(m_act, "Profile set", Toast.LENGTH_SHORT).show();
        return POST_CMD.REFRESH_LEFT_DEFAULT_RIGHT;

    case R.id.menu_delete_group: {

        // Test for All other contacts group, it can't be deleted
        if (MyGroups.isBaseGroup(m_group_id)) {

            Toast.makeText(m_act, "This group cannot be removed", Toast.LENGTH_LONG).show();
        } else {
            // Delete the group but not the contacts in the group.
            // Remove memory based and DB group title and data records matching group ID.
            // Sync transaction to companion device.
            MyGroups.deleteGroup(m_act, m_group_id, true);// Sync transaction is true

            // Group is now gone, select a default group
            int g_id = MyGroups.getDefaultGroup(Cryp.getCurrentAccount());
            Cryp.setCurrentGroup(g_id);

            return POST_CMD.REFRESH_LEFT_DEFAULT_RIGHT;
        }
        break;
    }
    case R.id.menu_add_group: {
        Intent intent = new Intent(m_act, EditGroupActivity.class);
        m_act.startActivity(intent);
        break;
    }
    case R.id.menu_edit_group: {
        if (MyGroups.isPseudoGroup(m_group_id))
            Toast.makeText(m_act, "Can't edit this group directly", Toast.LENGTH_SHORT).show();
        else {
            Intent intent = new Intent(m_act, EditGroupActivity.class);
            intent.putExtra(CConst.GROUP_ID_KEY, Cryp.getCurrentGroup());
            m_act.startActivity(intent);
        }
        break;
    }
    case R.id.menu_merge_group:
        MergeGroup.mergeGroup(m_act);
        break;
    //FUTURE integrate OpenPGP https://github.com/open-keychain/openpgp-api
    case R.id.menu_email_group:
        GroupSendEmail.emailGroup(m_act);
        break;
    case R.id.menu_text_group: {
        GroupSendSms.startGroupSms(m_act);
        break;
    }
    case R.id.menu_import_vcard: {

        if (hasPermission(READ_EXTERNAL_STORAGE)) {

            // Kickoff a browser activity here.
            // When user selects file, onActivityResult called with the result.
            Intent intent = new Intent();
            intent.setClass(m_act, FileBrowserImportVcf.class);
            m_act.startActivityForResult(intent, CConst.IMPORT_VCARD_BROWSE_ACTION);
        } else
            PermissionUtil.requestReadExternalStorage(m_act, CConst.IMPORT_VCARD_REQUEST_EXTERNAL_STORAGE);
        break;
    }
    case R.id.menu_import_single_contact: {

        if (hasPermission(READ_CONTACTS)) {
            /**
             * Launch the contact picker intent.
             * Results returned in onActivityResult()
             */
            Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
            m_act.startActivityForResult(contactPickerIntent, CConst.IMPORT_SINGLE_CONTACT_PICKER);
        } else
            PermissionUtil.requestReadExternalStorage(m_act, CConst.IMPORT_SINGLE_CONTACT_REQUEST_READ);
        break;
    }
    case R.id.menu_import_account_contacts: {

        if (hasPermission(READ_CONTACTS) && hasPermission(GET_ACCOUNTS)) {

            CloudImportDialog.openDialog(m_act);

        } else {
            if (!hasPermission(READ_CONTACTS)) {

                PermissionUtil.requestReadContacts(m_act, CConst.IMPORT_ACCOUNT_CONTACTS_REQUEST_READ_CONTACTS);
                break;
            }
            if (!hasPermission(GET_ACCOUNTS)) {

                PermissionUtil.requestGetAccounts(m_act, CConst.IMPORT_ACCOUNT_CONTACTS_REQUEST_GET_ACCOUNTS);
                break;
            }
        }
        break;
    }
    case R.id.menu_export_group: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {

            ExportVcf.exportGroupVcardAsync(m_act, m_group_id);
            Toast.makeText(m_act, "Exporting...", Toast.LENGTH_LONG).show();
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_export_account: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {
            ExportVcf.exportAccountVcardAsync(m_act, Cryp.getCurrentAccount());
            Toast.makeText(m_act, "Exporting...", Toast.LENGTH_LONG).show();
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_export_all: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {
            ExportVcf.exportAllVcardAsync(m_act);
            Toast.makeText(m_act, "Exporting...", Toast.LENGTH_LONG).show();
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_cleanup: {
        CleanupFragment f = CleanupFragment.newInstance(m_act);
        f.startFragment();
        break;
    }
    case R.id.menu_backup_to_email: {
        if (hasPermission(WRITE_EXTERNAL_STORAGE)) {
            BackupRestore.backupToEmail(m_act);
        } else {
            PermissionUtil.requestWriteExternalStorage(m_act, 0);
        }
        break;
    }
    case R.id.menu_backup_to_storage: {

        if (hasPermission(WRITE_EXTERNAL_STORAGE))
            BackupRestore.backupToStorage(m_act);
        else
            PermissionUtil.requestWriteExternalStorage(m_act, REQUEST_ID_BACKUP_TO_STORAGE);
        break;
    }
    case R.id.menu_backup_to_lan: {

        SqlFullSyncSource.getInstance().backupDiag(m_act);
        break;
    }
    case R.id.menu_accounts: {
        // import android.provider.Settings;
        m_act.startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS));
        break;
    }
    case R.id.menu_password_generator: {
        PasswordFragment f = PasswordFragment.newInstance(m_act);
        f.start();
        break;
    }
    case R.id.menu_empty_trash: {

        DialogUtil.emptyTrash(m_act, m_post_cmd_callbacks);
        break;
    }
    case R.id.menu_settings: {
        Intent intent = new Intent(m_act, SettingsActivity.class);
        m_act.startActivity(intent);
        break;
    }
    case R.id.menu_help: {
        String url = AppSpecific.APP_WIKI_URL;
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        m_act.startActivity(i);
        break;
    }
    case R.id.menu_developer: {

        DeveloperDialog.start(m_act);
        break;
    }
    default:
        if (DEBUG && m_item != null)
            LogUtil.log("SharedMenu.default: " + m_item.getTitle());
    }
    return POST_CMD.NIL;
}

From source file:de.luhmer.owncloudnewsreader.SettingsActivity.java

@SuppressWarnings("deprecation")
private static void bindDataSyncPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct) {
    String[] authorities = { "de.luhmer.owncloudnewsreader" };
    Intent intentSyncSettings = new Intent(Settings.ACTION_SYNC_SETTINGS);
    intentSyncSettings.putExtra(Settings.EXTRA_AUTHORITIES, authorities);

    if (prefFrag != null) {
        prefFrag.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefFrag.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefFrag.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_CACHE_SIZE));
    } else {/*from   w w  w.  j  a  va  2  s  .  c om*/
        prefAct.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefAct.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefAct.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_CACHE_SIZE));

    }

    clearCachePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {

            ((EditTextPreference) preference).getDialog().dismiss();

            checkForUnsycedChangesInDatabaseAndResetDatabase(_mActivity);
            return false;
        }
    });
}

From source file:com.quarterfull.newsAndroid.SettingsActivity.java

@SuppressWarnings("deprecation")
private static void bindDataSyncPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct) {
    String[] authorities = { "com.quarterfull.newsAndroid" };
    Intent intentSyncSettings = new Intent(Settings.ACTION_SYNC_SETTINGS);
    intentSyncSettings.putExtra(Settings.EXTRA_AUTHORITIES, authorities);

    if (prefFrag != null) {
        prefFrag.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefFrag.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefFrag.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_CACHE_SIZE));
    } else {/*from   w w  w . j  a v  a2s.  c o  m*/
        prefAct.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefAct.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefAct.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_CACHE_SIZE));

    }

    clearCachePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {

            ((EditTextPreference) preference).getDialog().dismiss();

            checkForUnsycedChangesInDatabaseAndResetDatabase(_mActivity);
            return false;
        }
    });
}

From source file:com.android.contacts.activities.PeopleActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mDisableOptionItemSelected) {
        return false;
    }/*from   w ww .j a  v a  2  s . c o m*/

    switch (item.getItemId()) {
    case android.R.id.home: {
        // The home icon on the action bar is pressed
        if (mActionBarAdapter.isUpShowing()) {
            // "UP" icon press -- should be treated as "back".
            onBackPressed();
        }
        return true;
    }
    case R.id.menu_settings: {
        startActivity(new Intent(this, ContactsPreferenceActivity.class));
        return true;
    }
    case R.id.menu_contacts_filter: {
        AccountFilterUtil.startAccountFilterActivityForResult(this, SUBACTIVITY_ACCOUNT_FILTER,
                mContactListFilterController.getFilter());
        return true;
    }
    case R.id.menu_search: {
        onSearchRequested();
        return true;
    }
    case R.id.menu_share:
        shareSelectedContacts();
        return true;
    case R.id.menu_join:
        joinSelectedContacts();
        return true;
    case R.id.menu_delete:
        deleteSelectedContacts();
        return true;
    case R.id.menu_import_export: {
        showImportExportDialogFragment();
        return true;
    }
    case R.id.menu_clear_frequents: {
        ClearFrequentsDialog.show(getFragmentManager());
        return true;
    }
    case R.id.menu_help:
        HelpUtils.launchHelpAndFeedbackForMainScreen(this);
        return true;
    case R.id.menu_accounts: {
        final Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
        intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] { ContactsContract.AUTHORITY });
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        ImplicitIntentsUtil.startActivityInAppIfPossible(this, intent);
        return true;
    }
    case R.id.menu_blocked_numbers: {
        final Intent intent = TelecomManagerUtil
                .createManageBlockedNumbersIntent((TelecomManager) getSystemService(Context.TELECOM_SERVICE));
        if (intent != null) {
            startActivity(intent);
        }
        return true;
    }
    case R.id.export_database: {
        final Intent intent = new Intent("com.android.providers.contacts.DUMP_DATABASE");
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        ImplicitIntentsUtil.startActivityOutsideApp(this, intent);
        return true;
    }
    }
    return false;
}