모바일 앱은 원격지에서 이메일 첨부 파일을 다운로드 할 수있는 옵션을 사용자에게 제공합니다. 원격 서버에 연결하고 콘텐츠를 다운로드하는 것은 별도의 스레드에서 수행됩니다. 취소 명령과 함께 사용자에게 표시됩니다. 내가 의사 코드를 제공하고 있습니다.취소 명령이 사용자에 의해 트리거 될 때 스레드 중지
new Thread(new Runnable()
public void run(){
try{
//open connection to remote server
//get data input stream
//create byte array of length attachment size
//show modeless dialog with the message "Downloading..."
for(int i=0;i<attachmentSize;i++){
//set the progress indicator of the modeless dialog based upon for iteration
//read the byte from input stream and store it in byte array
}
//open file connection outputstream and store the downloaded content as a file in mobile file system
//show dialog with the message "attachment successfully downloaded"
}
catch(IOException ioe) { }
catch(Exception ex) { }
}
).start();
이제 진행률 표시기가있는 대화 상자에 취소 명령을 추가하는 중입니다. 사용자가 모바일에서 "취소"명령을 클릭하면, dispose() 메소드를 호출하여 모덜리스 대화 상자를 삭제할 수 있습니다. 스트리밍을 통해 전자 메일 첨부 파일을 가져 오는 스레드를 갑자기 중지 할 수 있습니까? 이 문제를 해결할 수 있도록 도와주세요.