public class VerySlowTaskGMC extends AsyncTask<Void, Void, Void> {
    TokenModel model = TokenModel.getInstance();
    TokenDTO token = model.getToken(HomeActivity.this);
    String t = "";
    String _id;
    String dateupdate;
    LoginDTO logindto;

    public VerySlowTaskGMC(String id) {
      _id = id;
    }

    @Override
    protected Void doInBackground(Void... params) {
      String url = Constants.URL_REGISTER_PUSH + _id + "&provider=ANDROID";
      HttpEntity httpEntity = null;
      HttpClient client = new DefaultHttpClient();
      ServiceHandler sh = new ServiceHandler();
      try {
        client.getConnectionManager().getSchemeRegistry().register(sh.getMockedScheme());
      } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      HttpGet method = new HttpGet(url);
      method.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
      method.setHeader("Authorization", token.getToken_type() + " " + token.getAccess_token());
      try {
        HttpResponse response = client.execute(method);
        httpEntity = response.getEntity();

      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      } catch (ClientProtocolException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return null;
    }

    @Override
    protected void onPostExecute(Void result) {
      // TODO Auto-generated method stub
      super.onPostExecute(result);
    }
  }
  @SuppressLint("SimpleDateFormat")
  @Override
  public void onClick(View v) {
    Intent intent;
    switch (v.getId()) {
      case R.id.img_view_push_messages:
        if (InternetUtils.getInstance().isConnectingToInternet(HomeActivity.this)) {
          intent = new Intent(HomeActivity.this, ViewMessageActivity.class);

          startActivity(intent);
        } else {
          Toast.makeText(HomeActivity.this, "no net work", Toast.LENGTH_LONG).show();
        }

        break;

      case R.id.img_new_push_message:
        intent = new Intent(HomeActivity.this, UpdateAnimalActivity.class);

        startActivity(intent);
        break;
      case R.id.contact_us:
        intent = new Intent(HomeActivity.this, ContactUsActivity.class);
        startActivity(intent);
        break;
      case R.id.update:
        TokenModel tokenModel = TokenModel.getInstance();
        TokenDTO tokenDTO = tokenModel.getToken(HomeActivity.this);
        String dateExpires = tokenDTO.getExpires();
        Date date2 = null;
        Date date1 = null;
        String pattern = "EEE, dd MMM yyyy HH:mm:ss Z";
        SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.ENGLISH);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDay = sdf.format(new Date());
        String currentDayExpires = format.format(new Date());
        try {
          date1 = format.parse(currentDayExpires);
          date2 = format.parse(dateExpires);
          if (date1.compareTo(date2) < 0) {
            if (InternetUtils.getInstance().isConnectingToInternet(this)) {
              this.runOnUiThread(
                  new Runnable() {

                    @Override
                    public void run() {
                      String path = Constants.URL_CATEGORY;
                      String[] strs = path.split("/");
                      File file =
                          new File(
                              Environment.getExternalStorageDirectory()
                                  + "/"
                                  + Constants.APP_NAME
                                  + "/"
                                  + strs[4]
                                  + "/");
                      // deleteDirectory(file);
                      DeleteRecursive(file);
                      adapter.notifyDataSetChanged();
                      grid.invalidateViews();
                    }
                  });
              new AsystaskUpdateAnimal(currentDay, tokenDTO, HomeActivity.this).execute();
              flag = true;
              // arrData = new ArrayList<Object>();
              // InitData();
              // adapter = new AnimalCategoryMasterAdapter(this,
              // R.layout.grid_row,
              // arrData);
              adapter.notifyDataSetChanged();
            } else {
              Toast.makeText(HomeActivity.this, "no network", Toast.LENGTH_LONG).show();
            }
          }
        } catch (Exception e) {
          // TODO: handle exception
        }

        break;
      default:
        break;
    }
  }