[android-developers] Problem in Asynctask Execution in standby mode
Hi friends,
I am using AsyncTask concept to download data from
server.
private class DownloadTask extends AsyncTask<Void,Void,String>
{
private ProgressDialog progressDialog;
@Override
protected void onPreExecute()
{
super.onPreExecute();
progressDialog = new ProgressDialog(ActivityTab.this);
progressDialog.setProgress(10);
progressDialog.setSecondaryProgress(32);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage("Downloading...");
progressDialog.show();
}
protected String doInBackground(Void... params)
{
String result=" ";
result = download();
return result;
}
protected void onPostExecute(String result)
{
if(progressDialog.isShowing())
progressDialog.dismiss();
Toast.makeText(getApplicationContext(),"
"+result.toString(),Toast.LENGTH_LONG).show();
}
}
in download button click i called
new DownloadTask().execute();
This is working well. the thing is if device goes to standby mode
(Screen goes off) while showing this downloading.. progressbar mean my
application getting force closed. it says like IllegalStateException.
how to solve this probelm? it is there any way to prevent screen from
locking untill complete this download process? please help me.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home