4

I have TabActivity and each tab has ActivityGroup. In Forth Tab ForthActivityGroup has a MyAsyncActivity class. In MyAsyncAcitivity I have this Code. I have this Android AsyncTask Code. doInBackground(String.. params) is called and Log Printed on Android 2.3.3 but not Printed on Android 4.0. Please SomeBody Give Me Idea what I do?

public class getXML extends AsyncTask<String, Integer, String>{
        private final ProgressDialog dialog = new ProgressDialog(this);

        @Override
        protected void onPreExecute() {
            this.dialog.setMessage("Loading...");
            this.dialog.show();
        }

        @Override
        protected String doInBackground(String... params) {
            Log.d("Payment", "do background");

            return "result";
        }

        @Override
        protected void onPostExecute(String result) {
            if (this.dialog.isShowing()) {
                this.dialog.dismiss();
            }

    }
Ronit
  • 311
  • 1
  • 2
  • 16

1 Answers1

3

Use This:

AsyncTask task = new YourTask();
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
   task.execute(params);
} else {
   task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
}
Macrosoft-Dev
  • 2,195
  • 1
  • 12
  • 15