Example usage for android.provider Settings ACTION_SOUND_SETTINGS

List of usage examples for android.provider Settings ACTION_SOUND_SETTINGS

Introduction

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

Prototype

String ACTION_SOUND_SETTINGS

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

Click Source Link

Document

Activity Action: Show settings to allow configuration of sound and volume.

Usage

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

@Override
public void onHeaderClick(Header header, int position) {
    if (header.id == R.id.settings_header_sounds_and_vibration) {
        // If we don't have the permission to write to system settings, go to system sound
        // settings instead. Otherwise, perform the super implementation (which launches our
        // own preference fragment.
        if (!SettingsCompat.System.canWrite(this)) {
            Toast.makeText(this, getResources().getString(R.string.toast_cannot_write_system_settings),
                    Toast.LENGTH_SHORT).show();
            startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS));
            return;
        }/*from w  ww .  j  a  va 2  s.  c  o  m*/
    }
    super.onHeaderClick(header, position);
}

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  ww  w  . j ava 2s  .  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:de.baumann.thema.FragmentSound.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.sound, container, false);

    setHasOptionsMenu(true);//from   www.  j a va 2s  . co  m

    final String[] itemTITLE = {
            "Ouverture - Hymne" + " (Steven Testelin)" + " | " + getString(R.string.duration) + " 01:49",
            "Canon and Gigue in D major" + " | " + getString(R.string.duration) + "  00:45",
            "Epic" + " (Alexey Anisimov)" + " | " + getString(R.string.duration) + "  01:53",
            "Isn't it" + " | " + getString(R.string.duration) + " 00:01",
            "Jingle Bells Sms" + " | " + getString(R.string.duration) + " 00:04",
            "Wet" + " | " + getString(R.string.duration) + " 00:01", };

    final String[] itemURL = {
            Environment.getExternalStorageDirectory() + "/Android/data/de.baumann.thema/hymne.mp3",
            Environment.getExternalStorageDirectory() + "/Android/data/de.baumann.thema/canon.mp3",
            Environment.getExternalStorageDirectory() + "/Android/data/de.baumann.thema/epic.mp3",
            Environment.getExternalStorageDirectory() + "/Android/data/de.baumann.thema/isnt_it.mp3",
            Environment.getExternalStorageDirectory() + "/Android/data/de.baumann.thema/jingle_bells_sms.mp3",
            Environment.getExternalStorageDirectory() + "/Android/data/de.baumann.thema/wet.mp3", };

    final String[] itemDES = { "CC license: https://www.jamendo.com/track/1004091/ouverture-hymne",
            "CC license: https://musopen.org/music/2672/johann-pachelbel/canon-and-gigue-in-d-major/",
            "CC license: https://www.jamendo.com/track/1344095/epic",
            "CC license: https://notificationsounds.com/standard-ringtones/isnt-it-524",
            "CC license: https://notificationsounds.com/message-tones/jingle-bells-sms-523",
            "CC license: https://notificationsounds.com/notification-sounds/wet-431", };

    final String[] itemFN = { "hymne.mp3", "canon.mp3", "epic.mp3", "isnt_it.mp3", "jingle_bells_sms.mp3",
            "wet.mp3", };

    CustomListAdapter_Sound adapter = new CustomListAdapter_Sound(getActivity(), itemTITLE, itemURL, itemDES,
            itemDES);
    listView = (ListView) rootView.findViewById(R.id.bookmarks);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            String Selecteditem = itemURL[+position];
            final MediaPlayer mp = MediaPlayer.create(getActivity(), Uri.parse(Selecteditem));
            mp.start();

            Timer timer = new Timer();
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    mp.stop();
                }
            }, 5000);
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            final String SelecteditemMes = itemTITLE[+position];
            final String Selecteditem = itemURL[+position];
            final String SelecteditemTitle = itemFN[+position];
            final String SelecteditemUrl = itemDES[+position].substring(12);
            final CharSequence[] options = { getString(R.string.set_ringtone),
                    getString(R.string.set_notification), getString(R.string.set_alarm),
                    getString(R.string.play), getString(R.string.open) };

            new AlertDialog.Builder(getActivity())
                    .setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                        }
                    }).setItems(options, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {

                            if (options[item].equals(getString(R.string.set_ringtone))) {

                                File directory_al = new File(
                                        Environment.getExternalStorageDirectory() + "/Ringtones/");
                                if (!directory_al.exists()) {
                                    directory_al.mkdirs();
                                }

                                try {

                                    InputStream in;
                                    OutputStream out;
                                    in = new FileInputStream(Selecteditem);
                                    out = new FileOutputStream(Environment.getExternalStorageDirectory()
                                            + "/Ringtones/" + SelecteditemTitle);

                                    byte[] buffer = new byte[1024];
                                    int read;
                                    while ((read = in.read(buffer)) != -1) {
                                        out.write(buffer, 0, read);
                                    }
                                    in.close();

                                    // write the output file
                                    out.flush();
                                    out.close();

                                    MediaScannerConnection.scanFile(getActivity(),
                                            new String[] { Environment.getExternalStorageDirectory()
                                                    + "/Ringtones/" + SelecteditemTitle },
                                            null, new MediaScannerConnection.OnScanCompletedListener() {
                                                @Override
                                                public void onScanCompleted(String path, Uri uri) {
                                                    Intent intent2 = new Intent(Settings.ACTION_SOUND_SETTINGS);
                                                    intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                                    getActivity().startActivity(intent2);
                                                }
                                            });

                                } catch (Exception e) {
                                    Log.e("tag", e.getMessage());
                                }

                            } else if (options[item].equals(getString(R.string.set_notification))) {

                                File directory_al = new File(
                                        Environment.getExternalStorageDirectory() + "/Notifications/");
                                if (!directory_al.exists()) {
                                    directory_al.mkdirs();
                                }

                                try {

                                    InputStream in;
                                    OutputStream out;
                                    in = new FileInputStream(Selecteditem);
                                    out = new FileOutputStream(Environment.getExternalStorageDirectory()
                                            + "/Notifications/" + SelecteditemTitle);

                                    byte[] buffer = new byte[1024];
                                    int read;
                                    while ((read = in.read(buffer)) != -1) {
                                        out.write(buffer, 0, read);
                                    }
                                    in.close();

                                    // write the output file
                                    out.flush();
                                    out.close();

                                    MediaScannerConnection.scanFile(getActivity(),
                                            new String[] { Environment.getExternalStorageDirectory()
                                                    + "/Notifications/" + SelecteditemTitle },
                                            null, new MediaScannerConnection.OnScanCompletedListener() {
                                                @Override
                                                public void onScanCompleted(String path, Uri uri) {
                                                    Intent intent2 = new Intent(Settings.ACTION_SOUND_SETTINGS);
                                                    intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                                    getActivity().startActivity(intent2);
                                                }
                                            });

                                } catch (Exception e) {
                                    Log.e("tag", e.getMessage());
                                }

                            } else if (options[item].equals(getString(R.string.set_alarm))) {

                                File directory_al = new File(
                                        Environment.getExternalStorageDirectory() + "/Alarms/");
                                if (!directory_al.exists()) {
                                    directory_al.mkdirs();
                                }

                                try {

                                    InputStream in;
                                    OutputStream out;
                                    in = new FileInputStream(Selecteditem);
                                    out = new FileOutputStream(Environment.getExternalStorageDirectory()
                                            + "/Alarms/" + SelecteditemTitle);

                                    byte[] buffer = new byte[1024];
                                    int read;
                                    while ((read = in.read(buffer)) != -1) {
                                        out.write(buffer, 0, read);
                                    }
                                    in.close();

                                    // write the output file
                                    out.flush();
                                    out.close();

                                    MediaScannerConnection.scanFile(getActivity(),
                                            new String[] { Environment.getExternalStorageDirectory()
                                                    + "/Alarms/" + SelecteditemTitle },
                                            null, new MediaScannerConnection.OnScanCompletedListener() {
                                                @Override
                                                public void onScanCompleted(String path, Uri uri) {
                                                    Snackbar.make(listView, R.string.set_alarm_suc,
                                                            Snackbar.LENGTH_LONG).show();
                                                }
                                            });

                                } catch (Exception e) {
                                    Log.e("tag", e.getMessage());
                                }

                                Snackbar.make(listView, getString(R.string.set_alarm_suc), Snackbar.LENGTH_LONG)
                                        .show();

                            } else if (options[item].equals(getString(R.string.play))) {
                                final MediaPlayer mp = MediaPlayer.create(getActivity(),
                                        Uri.parse(Selecteditem));

                                new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.play))
                                        .setMessage(SelecteditemMes).setPositiveButton(R.string.cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        mp.stop();
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setOnCancelListener(new DialogInterface.OnCancelListener() {
                                            @Override
                                            public void onCancel(DialogInterface dialog) {
                                                mp.stop();
                                                dialog.cancel();
                                            }
                                        }).show();
                                mp.start();
                            } else if (options[item].equals(getString(R.string.open))) {
                                Uri uri = Uri.parse(SelecteditemUrl); // missing 'http://' will cause crashed
                                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                                startActivity(intent);
                            }
                        }
                    }).show();
            return true;
        }
    });

    return rootView;
}

From source file:com.stasbar.knowyourself.DeskClock.java

private void showSilentRingtoneSnackbar() {
    final OnClickListener changeClickListener = new OnClickListener() {
        @Override//www  .  ja v  a 2  s . c  o  m
        public void onClick(View v) {
            startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }
    };

    SnackbarManager.show(createSnackbar(R.string.silent_default_alarm_ringtone)
            .setAction(R.string.change_default_alarm_ringtone, changeClickListener));
}

From source file:com.wizardsofm.deskclock.DeskClock.java

private void showSilentRingtoneSnackbar() {
    final OnClickListener changeClickListener = new OnClickListener() {
        @Override/*from  w  ww  .ja va2s .co m*/
        public void onClick(View v) {
            startActivity(new Intent(Settings.ACTION_SOUND_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }
    };

    SnackbarManager.show(createSnackbar(com.wizardsofm.deskclock.R.string.silent_default_alarm_ringtone)
            .setAction(com.wizardsofm.deskclock.R.string.change_default_alarm_ringtone, changeClickListener));
}