Example usage for android.telecom TelecomManager ACTION_SHOW_CALL_SETTINGS

List of usage examples for android.telecom TelecomManager ACTION_SHOW_CALL_SETTINGS

Introduction

In this page you can find the example usage for android.telecom TelecomManager ACTION_SHOW_CALL_SETTINGS.

Prototype

String ACTION_SHOW_CALL_SETTINGS

To view the source code for android.telecom TelecomManager ACTION_SHOW_CALL_SETTINGS.

Click Source Link

Document

The android.content.Intent action used to show the call settings page.

Usage

From source file:com.android.dialer.settings.DialerSettingsActivity.java

@Override
public void onBuildHeaders(List<Header> target) {
    Header displayOptionsHeader = new Header();
    displayOptionsHeader.titleRes = R.string.display_options_title;
    displayOptionsHeader.fragment = DisplayOptionsSettingsFragment.class.getName();
    target.add(displayOptionsHeader);/*from  w  w  w  .ja  v a 2s  .c o m*/

    Header soundSettingsHeader = new Header();
    soundSettingsHeader.titleRes = R.string.sounds_and_vibration_title;
    soundSettingsHeader.fragment = SoundSettingsFragment.class.getName();
    soundSettingsHeader.id = R.id.settings_header_sounds_and_vibration;
    target.add(soundSettingsHeader);

    if (CompatUtils.isMarshmallowCompatible()) {
        Header quickResponseSettingsHeader = new Header();
        Intent quickResponseSettingsIntent = new Intent(TelecomManager.ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS);
        quickResponseSettingsHeader.titleRes = R.string.respond_via_sms_setting_title;
        quickResponseSettingsHeader.intent = quickResponseSettingsIntent;
        target.add(quickResponseSettingsHeader);
    }

    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    // "Call Settings" (full settings) is shown if the current user is primary user and there
    // is only one SIM. Before N, "Calling accounts" setting is shown if the current user is
    // primary user and there are multiple SIMs. In N+, "Calling accounts" is shown whenever
    // "Call Settings" is not shown.
    boolean isPrimaryUser = isPrimaryUser();
    if (isPrimaryUser && TelephonyManagerCompat.getPhoneCount(telephonyManager) <= 1) {
        Header callSettingsHeader = new Header();
        Intent callSettingsIntent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS);
        callSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        callSettingsHeader.titleRes = R.string.call_settings_label;
        callSettingsHeader.intent = callSettingsIntent;
        target.add(callSettingsHeader);
    } else if (BuildCompat.isAtLeastN() || isPrimaryUser) {
        Header phoneAccountSettingsHeader = new Header();
        Intent phoneAccountSettingsIntent = new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS);
        phoneAccountSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        phoneAccountSettingsHeader.titleRes = R.string.phone_account_settings_label;
        phoneAccountSettingsHeader.intent = phoneAccountSettingsIntent;
        target.add(phoneAccountSettingsHeader);
    }
    if (FilteredNumberCompat.canCurrentUserOpenBlockSettings(this)) {
        Header blockedCallsHeader = new Header();
        blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label;
        blockedCallsHeader.intent = FilteredNumberCompat.createManageBlockedNumbersIntent(this);
        target.add(blockedCallsHeader);
        migrationStatusOnBuildHeaders = FilteredNumberCompat.hasMigratedToNewBlocking();
    }
    if (isPrimaryUser && (TelephonyManagerCompat.isTtyModeSupported(telephonyManager)
            || TelephonyManagerCompat.isHearingAidCompatibilitySupported(telephonyManager))) {
        Header accessibilitySettingsHeader = new Header();
        Intent accessibilitySettingsIntent = new Intent(TelecomManager.ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS);
        accessibilitySettingsHeader.titleRes = R.string.accessibility_settings_title;
        accessibilitySettingsHeader.intent = accessibilitySettingsIntent;
        target.add(accessibilitySettingsHeader);
    }
}