我有AsyncTask处理一些后台HTTP的东西.AsyncTask按计划运行(警报/服务),有时用户手动执行它.
我从SQLite处理记录,我注意到服务器上的双帖,它告诉我有时计划的任务运行,同时用户手动运行它,导致相同的记录从DB读取和处理两次.我在处理后删除了记录,但仍然得到了这些记录.
我应该怎么处理?也许组织某种排队?
我正在使用基于Android系列教程的以下脚本:使用Progress Dialog下载文件,将多个视频文件从Internet下载到SD卡.它在下载过程中显示进度条.
public class MyDownload extends Activity {
public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
private Button startBtn;
private ProgressDialog mProgressDialog;
private String videoPath = "http://my_site.com/test_videos/";
private String[] fileNames = {"file1.mp4","file2.mp4"};
private TextView tv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startBtn = (Button)findViewById(R.id.startBtn);
startBtn.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
startDownload();
}
});
}
private void startDownload() {
tv = (TextView) findViewById(R.id.TextView01);
if(checkExternalMedia()==true) {
File …Run Code Online (Sandbox Code Playgroud)