Example usage for android.provider Settings EXTRA_AUTHORITIES

List of usage examples for android.provider Settings EXTRA_AUTHORITIES

Introduction

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

Prototype

String EXTRA_AUTHORITIES

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

Click Source Link

Document

Activity Extra: Limit available options in launched activity based on the given authority.

Usage

From source file:Main.java

/**
 * When adding account/*w  w  w .j  av  a 2s . co m*/
 * open the same UI screen for user to choose account
 */
public static Intent getIntentForAddingAccount() {
    final Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] { ContactsContract.AUTHORITY });
    return intent;
}

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.voidsink.anewjkuapp.activity.MainActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void StartCreateAccount(Context context) {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        context.startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT).putExtra(Settings.EXTRA_ACCOUNT_TYPES,
                new String[] { KusssAuthenticator.ACCOUNT_TYPE }));
    } else {/*from  w ww.ja v a2s.  c o  m*/
        context.startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT).putExtra(Settings.EXTRA_AUTHORITIES,
                new String[] { CalendarContractWrapper.AUTHORITY() }));
    }
}

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

public static void startAddAccountActivity(Context context) {
    Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
    intent.putExtra(Settings.EXTRA_AUTHORITIES, Array.of(AccountProvider.AUTHORITY));
    if (Build.VERSION.SDK_INT >= 18) {
        intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, Array.of(AccountUtils.getAccountType(context)));
    }// www  .j  a  va  2s  .  co  m
    context.startActivity(intent);
}

From source file:com.android.calendar.event.CreateEventDialogFragment.java

private void setDefaultCalendarView(Cursor cursor) {
    if (cursor == null || cursor.getCount() == 0) {
        // Create an error message for the user that, when clicked,
        // will exit this activity without saving the event.
        dismiss();/*from   w ww.ja  va2 s.c  o m*/
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.no_syncable_calendars).setIconAttribute(android.R.attr.alertDialogIcon)
                .setMessage(R.string.no_calendars_found)
                .setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        final Activity activity = getActivity();
                        if (activity != null) {
                            Intent nextIntent = new Intent(Settings.ACTION_ADD_ACCOUNT);
                            final String[] array = { "com.android.calendar" };
                            nextIntent.putExtra(Settings.EXTRA_AUTHORITIES, array);
                            nextIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                            activity.startActivity(nextIntent);
                        }
                    }
                }).setNegativeButton(android.R.string.no, null);
        builder.show();
        return;
    }

    String defaultCalendar = null;
    final Activity activity = getActivity();
    if (activity != null) {
        defaultCalendar = Utils.getSharedPreference(activity, GeneralPreferences.KEY_DEFAULT_CALENDAR,
                (String) null);
    } else {
        Log.e(TAG, "Activity is null, cannot load default calendar");
    }

    int calendarOwnerIndex = cursor.getColumnIndexOrThrow(Calendars.OWNER_ACCOUNT);
    int accountNameIndex = cursor.getColumnIndexOrThrow(Calendars.ACCOUNT_NAME);
    int accountTypeIndex = cursor.getColumnIndexOrThrow(Calendars.ACCOUNT_TYPE);

    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
        String calendarOwner = cursor.getString(calendarOwnerIndex);
        if (defaultCalendar == null) {
            // There is no stored default upon the first time running.  Use a primary
            // calendar in this case.
            if (calendarOwner != null && calendarOwner.equals(cursor.getString(accountNameIndex))
                    && !CalendarContract.ACCOUNT_TYPE_LOCAL.equals(cursor.getString(accountTypeIndex))) {
                setCalendarFields(cursor);
                return;
            }
        } else if (defaultCalendar.equals(calendarOwner)) {
            // Found the default calendar.
            setCalendarFields(cursor);
            return;
        }
    }
    cursor.moveToFirst();
    setCalendarFields(cursor);
}

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 w ww . j ava 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: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  .ja  v a  2 s  . 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.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 {/* www. j a  v a  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.android.calendar.event.EditEventView.java

@Override
public void onClick(DialogInterface dialog, int which) {
    if (dialog == mNoCalendarsDialog) {
        mDone.setDoneCode(Utils.DONE_REVERT);
        mDone.run();//from  w  ww  . j a  v a 2 s  .  c  o  m
        if (which == DialogInterface.BUTTON_POSITIVE) {
            Intent nextIntent = new Intent(Settings.ACTION_ADD_ACCOUNT);
            final String[] array = { "com.android.calendar" };
            nextIntent.putExtra(Settings.EXTRA_AUTHORITIES, array);
            nextIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            mActivity.startActivity(nextIntent);
        }
    }
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mDisableOptionItemSelected) {
        return false;
    }//www .  j a v a  2s  .  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;
}