@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; }
private HttpResponse doResponse(String url) { // Use our connection and data timeouts as parameters for our // DefaultHttpClient HttpClient httpclient = new DefaultHttpClient(getHttpParams()); ServiceHandler sh = new ServiceHandler(); try { httpclient.getConnectionManager().getSchemeRegistry().register(sh.getMockedScheme()); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } HttpResponse response = null; try { switch (taskType) { case POST_TASK: HttpPost httppost = new HttpPost(url); // Add parameters httppost.setEntity(new UrlEncodedFormEntity(params)); response = httpclient.execute(httppost); break; case GET_TASK: HttpGet httpget = new HttpGet(url); httpget.setHeader( "Authorization", "Bearer pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg"); // response.setHeader("Authorization", // "Bearer // pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg"); // httpget.addHeader("Authorization", // "Bearer // pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg"); Client client = new Client(); // response = client. response = httpclient.execute(httpget); // response.addHeader("Authorization", // "Bearer // pOuJzg0Y0FtJpO-Ugson2P_8dbmvaDiBZs7Z-v_2eIgGgUfFsiWS-TOIkNlquCQGHuu3OyeWCFVIB7xJjEp6nKg9iY1-gzRfjHtdvBk7MVemtm6Ksf5AmmKmuZleLR_-bNMorwUOqTs0BCjAomM6h2peaXA3LTJ_-V6CDpnKVmmfTf0DvVQYBsbtLG94sSAGUToxjhw9GQhkukkSLvMIYMRKt-R5M2walOq63_eJx17y7HQxlxjOffR41wq4sANewOFlIOuf2czn2QP_FuVg_2SwUpeQctMGYwSgLC7H2gUPFtWzSWB9AhG4Pfwfmy0cd4mxZrrPBglehg8_VpK0pzXpEDMYJ-mBtpZOkAaTXSr0f8aw8Y2CMCmLgRUtC5_JA9NtLhJ6TEBDeNco8Fj6ZfMyZEDxB6xg3MD0fgs7fkbqSUGj4bV54DbvrniSKQ9GwZM29tHXI1xzrvnTg0NIg1ul4kOSWiVeW88-PUlUTXA9kzKsE20CL_CrbOJUlaFhSYHMz-KAisKgtUynMe0lUg"); break; } } catch (Exception e) { Log.e(TAG, e.getLocalizedMessage(), e); } return response; }