public void Ring(String path, intnum,String comment){
Booleanb1 = false;
Booleanb2 = false;
Booleanb3 = false;
if(num== 1){
b1= true;
}elseif(num == 2){
b2= true;
}else{
b3= true;
}
Filesdfile = new File(path);
ContentValuesvalues = new ContentValues();
values.put(MediaStore.MediaColumns.DATA,sdfile.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE,sdfile.getName());
values.put(MediaStore.MediaColumns.MIME_TYPE,"audio/*");
values.put(MediaStore.Audio.Media.IS_RINGTONE,b1);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION,b2);
values.put(MediaStore.Audio.Media.IS_ALARM,b3);
values.put(MediaStore.Audio.Media.IS_MUSIC,false);
Uriuri = MediaStore.Audio.Media.getContentUriForPath(sdfile.getAbsolutePath());
UrinewUri = this.getContentResolver().insert(uri, values);
RingtoneManager.setActualDefaultRingtoneUri(this,RingtoneManager.TYPE_RINGTONE, newUri);
Toast.makeText(getApplicationContext(),comment, Toast.LENGTH_SHORT).show();
System.out.println("setMyRingtone-----");
}
//ring set
public void setMyRingtone(Stringpath){
Ring(path,1,"success");
}
//tishiyin
public void setMyNotification(Stringpath){
Ring(path,2,"success");
}
public void setMyAlarm(Stringpath){
Ring(path,3,"success");
}
设置壁纸
public voidsetWallPaper(String pathName){
WallpaperManagermWallManager = WallpaperManager.getInstance(this);
Bitmapbit = BitmapFactory.decodeFile(pathName);
try {
mWallManager.setBitmap(bit);
}catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}