私はアンドロイド開発の初心者です。
自動ダウンローダー用のアプリを作成しました。
すべてのダウンロードは正常に機能し、SD カードに保存されますが、drm ファイルがデバイスで開かれません。
自己紹介ですが、拡張子が dd\dm のファイルをダウンロードしてみます。通常のブラウザで dd\dm ファイルをダウンロードすると、デバイスはそれらを dcf 拡張子に解凍します。
私のアプリはそれをしません...デバイスが再起動した場合、すべてが正しいことに気づきました。実際、デバイスはこのファイルの拡張子をdcfに変更し、この曲を再生できます。オリジネーターがデバイスを再起動しなかった場合、ファイル拡張子は .dd.dm のまま
mt コンテンツ タイプ: application/vnd.oma.drm.message
誰かが私がそれの世話をする必要があることを知っていますか??
これは私のコードです.....
class DownloadFileFromURL extends AsyncTask<String, String, String> {
/**
* Before starting background thread
* Show Progress Bar Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(progress_bar_type);
}
/**
* Downloading file in background thread
* */
@Override
protected String doInBackground(String... f_url) {
int count;
try {
URL url = new URL(f_url[0]);
URLConnection conection = url.openConnection();
conection.getContent();
conection.connect();
// getting file length
int lenghtOfFile = conection.getContentLength();
// Insert Information Of File to Array
getCurrentArray()[index].setSizeOfFile(OrangeFile.convertToStringRepresentation(lenghtOfFile));
getCurrentArray()[index].setMimeOfFile(conection.getContentType());
// input stream to read file - with 8k buffer
InputStream input = new BufferedInputStream(url.openStream(), 8192);
// Output stream to write file
OutputStream output = new FileOutputStream(mPath + getCurrentArray()[index].getNameOfFile() + "." + getCurrentArray()[index].getExtOfFile());
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
// publishing the progress....
// After this onProgressUpdate will be called
publishProgress(""+(int)((total*100)/lenghtOfFile));
// writing data to file
output.write(data, 0, count);
}
// flushing output
output.flush();
// closing streams
output.close();
input.close();
} catch (Exception e) {
Log.e("Error: ", e.getMessage());
}
return null;
}