title: Cannot pass result of asynctask back
body: <p>I separated asynctask to separate class, but now I have error, when passing result back. I am tring to do it using interface to utilise callback feature. Can you tell me where is error? (<code>line 40 is callback.onDeleteAdd(result);
  </code>)</p>
  
  <p>interface</p>
  
  <pre><code>public interface DeleteAddInterface {
      public void onDeleteAdd(JSONObject result);
  }
  </code></pre>
  
  <p>asynctask</p>
  
  <pre><code>public class DeleteAdd extends AsyncTask&lt;Advert, Void, JSONObject&gt; {
      private DeleteAddInterface callback;
      private int atempt = 0;
      private Advert advert;
  
      public DeleteAdd(int atempt) {
          this.atempt = atempt;
      }
  
      public DeleteAdd() {
  
      }
  
      @Override
      protected JSONObject doInBackground(Advert... advert) {
          this.advert = advert[0];
          if (atempt &lt; 5) {
              UserFunctions u = new UserFunctions();
              return u.getNewAdd(advert[0].getId());
          } else
              return null;
      }
  
      @Override
      protected void onPostExecute(JSONObject result) {
          super.onPostExecute(result);
          if (result == null) {
              DeleteAdd add = new DeleteAdd(atempt + 1);
              add.execute(advert);
          } else {
              callback.onDeleteAdd(result);
          }
      }
  
  }
  </code></pre>
  
  <p>activity</p>
  
  <pre><code>public class AddToCheckActivity extends ErrorActivity implements DeleteAddInterface{
  
  @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
                  DeleteAdd dAdd = new DeleteAdd();
          dAdd.execute(adv);
  
  @Override
      public void onDeleteAdd(JSONObject result) {
          Intent i = new Intent(getApplicationContext(),
                  MyAddPrepareActivity.class);
          startActivity(i);
          finish();
  
      }
  }
  </code></pre>
  
  <p>error</p>
  
  <pre><code>10-27 02:16:26.322: E/AndroidRuntime(12664): FATAL EXCEPTION: main
  10-27 02:16:26.322: E/AndroidRuntime(12664): java.lang.NullPointerException
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at networkOperations.DeleteAdd.onPostExecute(DeleteAdd.java:40)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at networkOperations.DeleteAdd.onPostExecute(DeleteAdd.java:1)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at android.os.AsyncTask.finish(AsyncTask.java:631)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at android.os.Handler.dispatchMessage(Handler.java:99)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at android.os.Looper.loop(Looper.java:158)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at android.app.ActivityThread.main(ActivityThread.java:5751)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at java.lang.reflect.Method.invoke(Method.java:511)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
  10-27 02:16:26.322: E/AndroidRuntime(12664):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>