Мне нужна помощь для загрузки изображения на сервер. Ниже код работает нормально на всех устройствах, кроме moto g5 plus.
compileSdkVersion 22
buildToolsVersion '22 .0.1 '
public void uploadFile() {
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, TIME_OUT_CONNECTION);
HttpConnectionParams.setSoTimeout(httpParameters, TIME_OUT_SOCKET);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
httpClient.setParams(httpParameters);
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("FirstName", userInfo.getFirst_name()));
String paramsString = URLEncodedUtils.format(nameValuePairs, "UTF-8");
HttpPost httpPost = new HttpPost(REGISTERATION_API + "?" + paramsString);
InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(new File("file path")), -1);
reqEntity.setContentType("binary/octet-stream");
reqEntity.setChunked(true); // Send in multiple parts if needed
httpPost.setEntity(reqEntity);
HttpResponse response = httpClient.execute(httpPost);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
status = line;
}
} catch (Exception e) {
status = e.getMessage();
}
}