Async Task are UI Threads, probably that's the reason.. try creating
Threads from any bound Services to perform the download and retreive the
download status from service and update that in the UI whenever required..

On Thu, Jan 19, 2012 at 7:17 PM, sktniran <[email protected]>wrote:

> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to