개발환경 : 안드로이드 1.6


목적 : 동영상파일(5mb) 을 다운로드 하는 동안 다른 동작을 수행 할 수 있게..


개요 : 버튼을 클릭하면, 정해진 웹주소로 부터 동영상 파일을 다운로드, 다운로드하는 동안 다른 작업을 수행할 수 있음.



다운로드하는 기능을 서비스로 만들어서 구현을 하고 싶은데, 2.0 이상에 있는 Download Manager 를 사용하지 않고 

Bakcground 에서 어떻게 동작하게 해야 하는지 모르겠습니다.


열심히 구글링을 해도 여의치가 않네요~


고수님들 도와주세요.



 참. 이것저것 해본 결과 아래 기능이 Activity 를 extends 하지 않으면 동작을 하지 않습니다.

* downloadFromURL()



public void downloadFromUrl(){
 
		String videoUrl = "http://192.168.0.101/server/video.avi";
		String videoFileName = "test.avi";
		long latestId = -1;
		InputStream inputStream = null;
		FileOutputStream fileOutputStream = null;
		byte[] buf = new byte[100];
		try {
			inputStream = new URL("videoUrl).openStream();
			fileOutputStream = openFileOutput(videoFileName, MODE_WORLD_READABLE);
			//fileOutputStream = openFileOutput(videoFileName, MODE_WORLD_READABLE);
			int cnt = 0;
			while((cnt=inputStream.read(buf))!= -1){
				fileOutputStream.write(buf, 0, cnt);
				fileOutputStream.flush();
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				if(inputStream != null)inputStream.close();
				if(fileOutputStream != null)fileOutputStream.close();
			}catch(IOException e){
			}
		}
	}


어떻게 해야 할까요?? ㅠ_ㅠ