title: data load twice... means AsyncTask onPostExecute load same data twice?
body: <p>data load twice... means AsyncTask onPostExecute load same data twice?
  my <strong>AsyncTask onPostExecute</strong> run twice it load same data... 
  I am running async task to load results from a server. to show the data in gridview but the data show twice time..I am confused on why the AsyncTask outputs the data twice.
  <strong>Please Help me</strong>
  Here is my code:</p>
  
  <pre><code>public class InfoAccountsascyn extends AsyncTask &lt;String, String, String&gt;{
  
      String result;
      String s;
      private Activity activity;
      private String url;
      private String user_id;
      private ProgressDialog pDialog;
      JSONObject json;
      JSONParser jsonParser = new JSONParser();
      private static final String TAG_SUCCESS = "Success";
      int Success;
  
      public InfoAccountsascyn(Activity activity, String url,String user_id) {
          super();
          this.activity = activity;
          this.url = url;
          this.user_id=user_id;
      }
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          pDialog = new ProgressDialog(activity);
          pDialog.setMessage("Loading Items...");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(true);
          pDialog.setCanceledOnTouchOutside(false);
          pDialog.show();
      }
  
      protected String doInBackground(String... args) {
          try {
  
              List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
              params.add(new BasicNameValuePair("customer_id", user_id));
              //if(Last_id!=null){
              // params.add(new BasicNameValuePair("last_product_id", Last_id));
              // }
  
              json = jsonParser.makeHttpRequest(url, "POST", params);
  
              Success = json.getInt(TAG_SUCCESS);
          } catch (JSONException e) {
              e.printStackTrace();
          }
          if (Success == 1) {
              result = json.toString();
          }else{
              try {
                  result = json.getString("CartData");
                  //s=result;
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
          return result;
      }
  
      protected void onPostExecute(String result) {
          ((DetaildAddress) activity).parseJsonResponse(result);
          pDialog.dismiss();
  
     }
     }
  </code></pre>
  
  <p><strong>this is parseJsonResponse</strong></p>
  
  <pre><code>public void parseJsonResponse(String result) {
  
  String res = result;
      if (res !=null) {
          try {
              JSONObject jObjects = new JSONObject(result);
              JAS = jObjects.getJSONArray("Data");
              for (int i = 0; i &lt; JAS.length(); i++) {
                  JSONObject c = JAS.getJSONObject(i);
                  DetailedAddressInfo productinfo = new DetailedAddressInfo();
                  productinfo.setFirstname(c.optString("firstname"));
                  productinfo.setLastname(c.optString("lastname"));
                  productinfo.setStreet(c.optString("street"));
                  productinfo.setCity(c.optString("city"));
                  productinfo.setRegion(c.optString("region"));
                  productinfo.setPostcode(c.optString("postcode"));
                  productinfo.setTelephone(c.optString("telephone"));
                  productinfo.setFax(c.optString("fax"));
                  productinfo.setAddId(c.optString("customer_address_id"));
                  productinfo.setBilling(c.optString("is_default_billing"));
                  productinfo.setShipping(c.optString("is_default_shipping"));
  
  
                  products.add(productinfo);
                  if (i == JAS.length() - 1) {
                      Last_id = c.optString("product_id");
                  }
              }
              adapter = new DetailedAddressAdapter(DetaildAddress.this, R.layout.deshbord_address, products);
              gridView.setAdapter(adapter);
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
      else {
          new AlertDialog.Builder(DetaildAddress.this)
          .setTitle("No Address Available")
                  .setMessage("You Want to Add New Address")
                  .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                          Intent intent=new Intent(DetaildAddress.this,NewAddress.class);
                          String ok = "0";
                          intent.putExtra("ok", ok);
                          startActivity(intent);
                      }
                  })
                  .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                          // do nothing
                      }
                  })
                  .setIcon(android.R.drawable.ic_dialog_alert)
                  .show();
      } if (pDialog != null) {
          pDialog.dismiss();
      }
  }
  </code></pre>
  
  <p><strong>this is OnCreate where I call AsyncTask</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_detaild_address);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      stub = (ViewStub) findViewById(R.id.layout_stub);
      stub.setLayoutResource(R.layout.content_detaild_address);
      View inflated = stub.inflate();
  
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      String check = "0";
      String chEck;
      DBHandler db = new DBHandler(DetaildAddress.this);
      List&lt;DBconnector&gt; Contacts = db.getAllContacts();
      for (DBconnector cn : Contacts) {
          chEck = cn.getActive();
          if(chEck != null){
              if (chEck.equals("1")){
                  check = chEck;
              }
          }
      }
      if (check.equals("1")) {
          List&lt;DBconnector&gt; contacts = db.getActiveData();
  
          for (DBconnector c : contacts) {
              Customer_id = c.getCustomer_id();
              //new CheckAddress().execute();
              boolean connected = false;
              ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
              if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
                      connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
                  //we are connected to a network
                  new InfoAccountsascyn(DetaildAddress.this,url_address,Customer_id).execute();
              }
              else
              {
                  Toast.makeText(DetaildAddress.this,"Internet Connection is not Available",Toast.LENGTH_LONG).show();
                  Intent intent=new Intent(DetaildAddress.this,HomeActivity.class);
                  startActivity(intent);
                  connected = false;
              }
  
          }
  
      }
      else{
          Toast.makeText(DetaildAddress.this, "Please login First", Toast.LENGTH_LONG).show();
          Intent intent = new Intent(DetaildAddress.this, UserLogin.class);
          startActivity(intent);
      }
      gridView = (GridView) findViewById(R.id.gridView1);
      myLastVisiblePos = gridView.getFirstVisiblePosition();
      products = new ArrayList&lt;DetailedAddressInfo&gt;();
      //gridView.setAdapter(new DetailedAddressAdapter(DetaildAddress.this, R.layout.deshbord_address, products));
  
      TextView newaddress=(TextView)findViewById(R.id.newaddress);
      newaddress.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent=new Intent(DetaildAddress.this,NewAddress.class);
              String ok = "0";
              intent.putExtra("ok", ok);
              startActivity(intent);
          }
      });
  }
  </code></pre>