上で動作します:着メロは私は2つの質問を持っているアンドロイド2.3のようにサイレント設定されますが、4.0.3
私は私の
saveas(ressound);
アンドロイド4.0.3デバイス上(stealthcopter.comに触発)着メロを呼び出すと着信音としてきちんと活性化されますが、2.3.3のデバイスでは選択した着信音は無音です。私のコードでどこが間違っていたのですか?私が知りたいのは、ファイルを削除する方法です。もっと重要なことに、メディアストアからそれを取り出す方法は、SDからSDを削除すると自動的に行われますか?
UPDATE:フォルダ全体を加えたコンテンツを削除する
追加コードは、良いときれいな作品!私は、ボタンを押すと、このコードを呼び出すようにしてください
(下記参照):
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
しかし、それはメディアストアを一掃しません、それは、再起動して動作します。 私はdevツール内でメディアスキャンを試みましたが、それは動作しません。彼らはいくつかのアプリを再起動する必要があるが、デバイス全体を再起動せずに利用可能な着メロのリストを表示する責任を負うサービスを再起動する方法について言及していますか?
変数:
String soundname;
int ressound;
int savetype;
String path="/sdcard/mysounds/";
savetype = RingtoneManager.TYPE_RINGTONE;
ressound = R.raw.sound1;
soundname = "sound1";
名前を付けて保存(ressound)。
//save as
public boolean saveas(int ressound){
byte[] buffer=null;
InputStream fIn = getBaseContext().getResources().openRawResource(ressound);
int size=0;
try {
size = fIn.available();
buffer = new byte[size];
fIn.read(buffer);
fIn.close();
} catch (IOException e) {
return false;
}
String filename= soundname +".mp3";
boolean exists = (new File(path)).exists();
if (!exists){new File(path).mkdirs();}
FileOutputStream save;
try {
save = new FileOutputStream(path+filename);
save.write(buffer);
save.flush();
save.close();
} catch (FileNotFoundException e) {
return false;
} catch (IOException e) {
return false;
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://"+path+filename)));
File k = new File(path, filename);
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE, soundname);
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
values.put(MediaStore.Audio.Media.ARTIST, "Elvis");
values.put(MediaStore.Audio.Media.IS_RINGTONE, true);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
values.put(MediaStore.Audio.Media.IS_ALARM, true);
values.put(MediaStore.Audio.Media.IS_MUSIC, false);
//Insert it into the database
Uri newUri = this.getContentResolver().insert(MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()), values);
// set as ringtone
RingtoneManager.setActualDefaultRingtoneUri(this, savetype, newUri);
return true;
}
delete();
public void delete() {
File a = new File(path, "sound1.mp3");
a.delete();
File b = new File(path, "sound2.mp3");
b.delete();
}
deleteFiles(文字列パス);
public static void deleteFiles(String path) {
File file = new File(path);
if (file.exists()) {
String deleteCmd = "rm -r " + path;
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(deleteCmd);
} catch (IOException e) { }
}
}
現在市場に出回っている他のアプリがこの問題を抱えていますか? – John
ファイルが既に存在する場合は、ファイルが上書きされている可能性があります。 ....修正する方法がわからない。 – John
マップ全体とコンテンツを削除する削除機能を作った。それで、私は上記の仮説を確認しましたが、運はありません。 – John