4
I implemented these classes, but I can’t import them; the project was done in Android Studio.
public class HttpConnection {
public static String getSetDataWeb(WrapData wd){
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(wd.getUrl());
String answer = "";
try{
ArrayList<NameValuePair> valores = new ArrayList<NameValuePair>();
valores.add(new BasicNameValuePair("method", wd.getMethod()));
valores.add(new BasicNameValuePair("produto", wd.getProduto()));
valores.add(new BasicNameValuePair("marca", wd.getMarca()));
valores.add(new BasicNameValuePair("detalhe", wd.getDetalhe()));
valores.add(new BasicNameValuePair("img-mime", wd.getImage().getMime()));
valores.add(new BasicNameValuePair("img-image", wd.getImage().getBitmapBase64()));
httpPost.setEntity(new UrlEncodedFormEntity(valores));
HttpResponse resposta = httpClient.execute(httpPost);
answer = EntityUtils.toString(resposta.getEntity());
}
catch (UnsupportedEncodingException e) { e.printStackTrace(); }
catch (ClientProtocolException e) { e.printStackTrace(); }
catch (IOException e) { e.printStackTrace(); }
return(answer);
}
}
I’m unable to import. Despite declaring the import, it doesn’t happen.
– Carlos Ximendes
Caring isn’t enough. It’s in your classpath? Where did you declare the Apache library as a dependency? If not, see in the answer how you can do this.
– utluiz
I don’t know how to do this.
– Carlos Ximendes
See in the answer below the part of
build.gradle. Browse this file in your project and add the mentioned line where the dependencies are.– utluiz
But if you use this dependency, I have to redo my code; you could edit it?
– Carlos Ximendes