List of usage examples for android.media RingtoneManager isDefault
public static boolean isDefault(Uri ringtoneUri)
From source file:com.android.contacts.editor.EditorUiUtils.java
/** * Returns a ringtone string based on the ringtone URI and version #. *///from w w w .j av a 2s . co m public static String getRingtoneStringFromUri(Uri pickedUri, int currentVersion) { if (isNewerThanM(currentVersion)) { if (pickedUri == null) return ""; // silent ringtone if (RingtoneManager.isDefault(pickedUri)) return null; // default ringtone } if (pickedUri == null || RingtoneManager.isDefault(pickedUri)) return null; return pickedUri.toString(); }
From source file:com.silentcircle.contacts.detail.ContactLoaderFragment.java
private void handleRingtonePicked(Uri pickedUri) { if (pickedUri == null || RingtoneManager.isDefault(pickedUri)) { mCustomRingtone = null;/* ww w .ja va 2 s . com*/ } else { mCustomRingtone = pickedUri.toString(); } Intent intent = ScContactSaveService.createSetRingtone(mContext, mLookupUri, mCustomRingtone); mContext.startService(intent); }
From source file:com.example.mydemos.view.RingtonePickerActivity.java
@Override public View createTabContent(String tag) { Log.i("lys", "createTabContent tag == " + tag); if (tag.equals("tab_system")) { tabName = SYSTEM_TONE;//w w w. jav a2 s.c o m if (toneType == ALARM_TYPE) { where = MediaStore.Audio.Media.IS_ALARM; } else if (toneType == RINGTONE_TYPE) { where = MediaStore.Audio.Media.IS_RINGTONE; } else if (toneType == NOTIFICATION_TYPE) { where = MediaStore.Audio.Media.IS_NOTIFICATION; } } else if (tag.equals("tab_music")) { tabName = MUSIC_TONE; } else { tabName = RECORD_TONE; } Log.e("lys", "tabContent where == " + where); //String project[] = {" DISTINCT title ","_id","_data",MediaStore.Audio.Media.ALBUM,"track","year","is_music","is_ringtone","is_alarm","is_notification"}; switch (tabName) { case SYSTEM_TONE: toneCur = getCursor(tabName, where); //toneCur = getContentResolver().query( // MediaStore.Audio.Media.INTERNAL_CONTENT_URI,null,where, // null, MediaStore.Audio.Media.TITLE+" COLLATE LOCALIZED ASC"); //BaseUri = MediaStore.Audio.Media.INTERNAL_CONTENT_URI; break; case MUSIC_TONE: { where = "mime_type != 'audio/amr'" + " AND " + MediaStore.Audio.Media.TITLE + " != 'hangout_ringtone' AND " + MediaStore.Audio.Media.TITLE + " != 'Join Hangout' AND " + MediaStore.Audio.Media.TITLE + " != 'hangout_dingtone' "; toneCur = getCursor(tabName, where); //final String status = Environment.getExternalStorageState(); //if (status.equals(Environment.MEDIA_MOUNTED) || // status.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) //{ // toneCur = getContentResolver() // .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,null, // where, null, // MediaStore.Audio.Media.TITLE+" COLLATE LOCALIZED ASC"); //} //else //{ // toneCur = null; //} //BaseUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; break; } case RECORD_TONE: { //new String[] { "recordings" } //where = MediaStore.Audio.Media.ALBUM + " = 'Records' "; where = "mime_type = 'audio/amr'"; toneCur = getCursor(tabName, where); //final String status = Environment.getExternalStorageState(); //if (status.equals(Environment.MEDIA_MOUNTED) || // status.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) //{ // toneCur = getContentResolver().query( // MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,null, where, // null, // MediaStore.Audio.Media.DATE_ADDED+" COLLATE LOCALIZED ASC"); //} //else //{ // toneCur = null; //} //BaseUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; break; } default: return null; } Log.i("lys", "toneCur == " + toneCur); if (toneCur == null) { Log.e("lys", "createTabContent toneCur== null"); //listView.setEmptyView(findViewById(android.R.id.empty)); listView.setAdapter(null); listView.invalidate(); return listView; } if (mHasDefaultItem) { if (RingtoneManager.isDefault(mExistingUri)) { defaultItemChecked = true; silentItemChecked = false; mSelectedId = DEFAULT_ID; //mSelectedUri = mUriForDefaultItem; } } if (mHasSilentItem) { if (mExistingUri == null) { silentItemChecked = true; defaultItemChecked = false; mSelectedId = SILENT_ID; //mSelectedUri = null; } } if ((mSelectedId != DEFAULT_ID) && (mSelectedId != SILENT_ID)) { silentItemChecked = false; defaultItemChecked = false; if (mExistingUri != null) { Log.e("mExistingUri===", mExistingUri.toString()); mSelectedId = ContentUris.parseId(mExistingUri); } //mSelectedUri = mExistingUri; } adapter = new TabListAdapter(this, R.layout.tab_picker_item, toneCur, new String[] {}, new int[] {}); listView.setAdapter(adapter); listView.invalidate(); int index = getRingtonePosition(mExistingUri, tabName, where); if (mHasSilentItem) { index += 1; } if (mHasDefaultItem) { index += 1; } listView.setSelection(index); return listView; }