-3
A
답변
2
다운로드 파일의 경우 다음 코드를 사용할 수 있습니다.
private class DownloadFile extends AsyncTask<String, Integer, String>{
@Override
protected String doInBackground(String... url) {
int count;
try {
URL url = new URL("url of your .mp3 file");
URLConnection conexion = url.openConnection();
conexion.connect();
// this will be useful so that you can show a tipical 0-100% progress bar
int lenghtOfFile = conexion.getContentLength();
// downlod the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/sdcard/somewhere/nameofthefile.mp3");
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
// publishing the progress....
publishProgress((int)(total*100/lenghtOfFile));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {}
return null;
}
매니페스트 권한 :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
은 또한 수도 다음 링크를 참조하면 도움 :
how can i download audio file from server by url
Android:How to download the File from the server and save it in specific folder in sdcard
+0
작동하지 않습니까?! – user3187340
관련 문제
- 1. android 2.1의 서버에서 데이터 다운로드
- 2. 서버에서 Android 이미지를 다운로드 하시겠습니까?
- 3. Android MediaPlayer, 점진적 다운로드 오디오 지원 여부
- 4. FTP 서버에서 Android App으로 오디오 파일을 스트림
- 5. 강제로 오디오 스트림 다운로드
- 6. Firebase storage에서 오디오 다운로드
- 7. 오디오 파일을 점진적으로 다운로드
- 8. android : 비동기 FTP 서버에서 이미지 목록을 다운로드
- 9. 내 안드로이드 응용 프로그램의 서버에서 비디오 또는 오디오 파일을 다운로드
- 10. 오디오 html5 태그에서 다운로드
- 11. 오디오 파일을 iTunes에 다운로드
- 12. 웹 서버에서 스트리밍 오디오
- 13. android의 서버에서 mp3 파일 다운로드
- 14. Android 용 오디오 스트리밍
- 15. 서버에서 데이터 다운로드
- 16. 서버에서 iPhone으로 파일 다운로드
- 17. Android에서 서버에서 동시에 다운로드
- 18. 서버에서 AngularJS 다운로드 설정
- 19. 파일을 ftp 서버에서 다운로드
- 20. 서버에서 파일 다운로드
- 21. 서버에서 전체 폴더 다운로드
- 22. 서버에서 CSV 파일 다운로드
- 23. 서버에서 csv 파일 다운로드
- 24. 서버에서 파일 다운로드
- 25. HTTP 다운로드 Java 서버에서
- 26. 서버에서 파일 다운로드
- 27. 서버에서 파일 다운로드
- 28. 서버에서 이미지 다운로드
- 29. 서버에서 스로틀 다운로드
- 30. 서버에서 파일 다운로드
당신은 분명하지 질문입니다. 당신은 무엇을하길 원합니까 ? –
고마워요. 내가 버튼을 클릭하면 url 양식을 통해 오디오 서버에 오디오를 보내고 싶습니다. – user3187340