title: Exception in async task Android
body: <p>I am trying to get data from parse.com database but my app gets crash.</p>
  
  <p>This is my code</p>
  
  <pre><code>     private class RemoteDataTask extends AsyncTask&lt;Void, Void, Void&gt; {
          protected void onPreExecute() {
              super.onPreExecute();
              // Create a progress dialog
              mProgressDialog = new ProgressDialog(CategoryList.this);
  
              // mProgressDialog.setCancelable(false);
              mProgressDialog.setIndeterminate(false);
              // Show progress dialog
              mProgressDialog.show();
          }
  
          @Override
          protected Void doInBackground(Void... arg0) {
              // TODO Auto-generated method stub
  
              mylatlng = new LatLng(lat,lng);
              ParseGeoPoint latlng = new ParseGeoPoint(mylatlng.latitude,
                      mylatlng.longitude);
              try {
                  ParseQuery&lt;ParseObject&gt; query = new ParseQuery&lt;ParseObject&gt;(
                          tableName);
                  ParseQuery&lt;ParseObject&gt; userQuery = new ParseQuery&lt;ParseObject&gt;(
                          "_User");
                  query.whereNear("shopLatLng", latlng);
                  results = query.find();
                  for (ParseObject obj : results) {
                      validityDate = obj.getDate("validity");
                      if (validityDate.compareTo(dateToday) &gt; 0) {
                          Log.d("results", obj.toString());
                          map = new CategoryGridItem();
                          ParseFile itemImage = (ParseFile) obj.get("itemImage");
                          map.setItemImage(itemImage.getUrl());
                          map.setTitle((String) obj.get("couponTitle"));
                          Log.e("title", (String) obj.get("couponTitle"));
                          shopObjectId = (String) obj.get("userObject");
                          shopLatLng = (ParseGeoPoint) obj.get("shopLatLng");
                          map.setShopLatLng(new LatLng(shopLatLng.getLatitude(),
                                  shopLatLng.getLongitude()));
                          map.setValidityDate((Date) validityDate);
                          Log.e("date", validityDate.toString());
                          userQuery.getInBackground(shopObjectId,new GetCallback&lt;ParseObject&gt;() {
                          @Override
                          public void done(ParseObject object,ParseException e) {
                          // TODO Auto-generated method stub
                          ParseFile icon = (ParseFile) object.get("logo");
                          map.setShopName((String) object.get("shopName"));
                          Log.e("shopName",(String) object.get("shopName"));
                          map.setShopAddr((String) object.get("shopAddr"));
                          map.setIcon(icon.getUrl());
                          }
                          });
                          categoryItemList.add(map);
                      }
                  }
  
              } catch (Exception e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return null;
          }
  
          protected void onPostExecute(Void result) {
              adapter = new CategoryGridAdapter(CategoryList.this,categoryItemList);
              gridView.setAdapter(adapter);
              mProgressDialog.dismiss();
          }
  }
  </code></pre>
  
  <p>and this is my crash log</p>
  
  <pre><code>03-29 05:56:46.742: E/AndroidRuntime(1541): FATAL EXCEPTION: AsyncTask #1
  03-29 05:56:46.742: E/AndroidRuntime(1541): java.lang.RuntimeException: An error occured while         executing doInBackground()
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.lang.Thread.run(Thread.java:856)
  03-29 05:56:46.742: E/AndroidRuntime(1541): Caused by: java.lang.NullPointerException: println needs a message
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at android.util.Log.println_native(Native Method)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at android.util.Log.e(Log.java:231)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at fragments.CategoryList$RemoteDataTask.doInBackground(CategoryList.java:157)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at fragments.CategoryList$RemoteDataTask.doInBackground(CategoryList.java:1)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  03-29 05:56:46.742: E/AndroidRuntime(1541):     ... 5 more 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>03-29 05:56:52.531: E/WindowManager(1541): Activity fragments.CategoryList has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41035788 that was originally added here
  03-29 05:56:52.531: E/WindowManager(1541): android.view.WindowLeaked: Activity fragments.CategoryList has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41035788 that was originally added here
  03-29 05:56:52.531: E/WindowManager(1541):  at android.view.ViewRootImpl.&lt;init&gt;(ViewRootImpl.java:374)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.view.WindowManagerImplCompatModeWrapper.addView(WindowManagerImpl.java:149)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.view.Window$LocalWindowManager.addView(Window.java:547)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.Dialog.show(Dialog.java:277)
  03-29 05:56:52.531: E/WindowManager(1541):  at fragments.CategoryList$RemoteDataTask.onPreExecute(CategoryList.java:86)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.os.AsyncTask.execute(AsyncTask.java:534)
  03-29 05:56:52.531: E/WindowManager(1541):  at fragments.CategoryList.onCreate(CategoryList.java:57)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.Activity.performCreate(Activity.java:5008)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.os.Handler.dispatchMessage(Handler.java:99)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.os.Looper.loop(Looper.java:137)
  03-29 05:56:52.531: E/WindowManager(1541):  at android.app.ActivityThread.main(ActivityThread.java:4745)
  03-29 05:56:52.531: E/WindowManager(1541):  at java.lang.reflect.Method.invokeNative(Native Method)
  03-29 05:56:52.531: E/WindowManager(1541):  at java.lang.reflect.Method.invoke(Method.java:511)
  03-29 05:56:52.531: E/WindowManager(1541):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  03-29 05:56:52.531: E/WindowManager(1541):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  03-29 05:56:52.531: E/WindowManager(1541):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>