Android examples for android.media:RingtoneManager
get Ringtones Dialog
import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.database.Cursor; import android.media.AudioManager; import android.media.RingtoneManager; import android.net.Uri; import android.widget.ArrayAdapter; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; public class Main{ public static void getRingtonesDialog(Activity activity, Collection<String> items, int selected, DialogInterface.OnClickListener itemClickListener, DialogInterface.OnClickListener okClickListener, final DialogInterface.OnClickListener cancelClickListener) { AlertDialog.Builder builderSingle = new AlertDialog.Builder( activity);//from w w w . java 2 s. c om builderSingle.setTitle("Select Ringtone"); final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>( activity, android.R.layout.select_dialog_singlechoice); arrayAdapter.addAll(items); builderSingle.setNegativeButton(android.R.string.cancel, cancelClickListener); builderSingle.setPositiveButton(android.R.string.ok, okClickListener); builderSingle.setSingleChoiceItems(arrayAdapter, selected, itemClickListener); builderSingle.setCancelable(false); builderSingle.show(); } }