2013-07-02 57 views
0

嗯,我已经使用LWUI ImageDownloadService从网络下载图像。当下载进度时,进度对话框显示。我想通过按取消命令停止下载。但它仍在下载。我能做些什么来阻止下载?LWUIT无法终止连接请求

我的代码如下

public void actionPerformed(ActionEvent evt) { 
if (evt.getSource() == okCommand) { 
    final Form resultForm = new Form("Result"); 
    resultForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); 
    resultForm.show(); 
    Label mLabel = new Label(); 
    ImageDownloadService img = new ImageDownloadService("http://datastore04.rediff.com/h1500-w1500/thumb/69586A645B6D2A2E3131/s47kscdm7r4pjx05.D.0.Happy-Valentines-Day-Wallpaper-Image.jpg", mLabel); 
    NetworkManager.getInstance().addToQueue(img); 
    resultForm.addComponent(mLabel); 
    Progress progress = new Progress("Loading", img); 
    progress.setDisposeOnCompletion(true); 
    progress.show(); 
} 

我已经上传图片here

+0

可能重复的[Lwuit网络连接超时问题](http://stackoverflow.com/questions/17416994/lwuit-network-connection-timeout-issue) –

+0

无法设置超时,无法停止连接? –

+0

看看这个参考。这是我的答案http://stackoverflow.com/questions/13966033/how-to-handle-network-thread-calls-and-wait-progress-in-j2me/13969115#13969115 – neb1

回答

0

我的想法是......把这段代码在Thread并在Command逻辑停止这个线程。