public static void setMyAlarm(Context paramContext, String paramString) { File localFile = new File(paramString); ContentValues localContentValues = new ContentValues(); localContentValues.put( MediaStore.MediaColumns.DATA, localFile.getAbsolutePath()); localContentValues.put(MediaStore.MediaColumns.TITLE, localFile.getName()); localContentValues.put(MediaStore.MediaColumns.SIZE, Long.valueOf(localFile.length())); localContentValues.put(MediaStore.Audio.Media.IS_RINGTONE, Boolean.valueOf(false)); localContentValues.put(MediaStore.Audio.Media.IS_NOTIFICATION, Boolean.valueOf(false)); localContentValues.put(MediaStore.Audio.Media.IS_ALARM, Boolean.valueOf(true)); localContentValues.put(MediaStore.Audio.Media.IS_MUSIC, Boolean.valueOf(false)); Uri localUri = MediaStore.Audio.Media.getContentUriForPath(paramString); RingtoneManager.setActualDefaultRingtoneUri(paramContext, RingtoneManager.TYPE_ALARM, paramContext.getContentResolver().insert(localUri, localContentValues));}
public static void setMyRing(Context paramContext, String paramString) { File localFile = new File(paramString); ContentValues localContentValues = new ContentValues(); localContentValues.put( MediaStore.MediaColumns.DATA, localFile.getAbsolutePath()); localContentValues.put(MediaStore.MediaColumns.TITLE, localFile.getName()); localContentValues.put(MediaStore.Audio.Media.IS_RINGTONE, Boolean.valueOf(true)); Uri localUri = MediaStore.Audio.Media.getContentUriForPath(localFile.getAbsolutePath()); paramContext.getContentResolver().delete(localUri, "_data=\"" + localFile.getAbsolutePath() + "\"", null); RingtoneManager.setActualDefaultRingtoneUri(paramContext, RingtoneManager.TYPE_RINGTONE, paramContext.getContentResolver().insert(localUri, localContentValues)); }//短信出错 设置不成功 不知道原因public static void setMyMessage(Context paramContext, String paramString) { File localFile = new File(paramString); ContentValues localContentValues = new ContentValues(); localContentValues.put( MediaStore.MediaColumns.DATA, localFile.getAbsolutePath()); localContentValues.put(MediaStore.MediaColumns.TITLE, localFile.getName()); localContentValues.put(MediaStore.MediaColumns.SIZE, Long.valueOf(localFile.length())); localContentValues.put(MediaStore.Audio.Media.IS_RINGTONE, Boolean.valueOf(false)); localContentValues.put(MediaStore.Audio.Media.IS_NOTIFICATION, Boolean.valueOf(true)); localContentValues.put(MediaStore.Audio.Media.IS_ALARM, Boolean.valueOf(false)); localContentValues.put(MediaStore.Audio.Media.IS_MUSIC, Boolean.valueOf(false)); Uri localUri = MediaStore.Audio.Media.getContentUriForPath(paramString); RingtoneManager.setActualDefaultRingtoneUri(paramContext, RingtoneManager.TYPE_NOTIFICATION, paramContext.getContentResolver().insert(localUri, localContentValues)); }
把sd卡中的mp3设置为闹铃或来电提示音
最新推荐文章于 2022-05-20 20:12:45 发布