androidhttpclient

Android - MultipartEntity and dependencies

匆匆过客 提交于 2019-11-26 16:50:41
问题 I recently migrate my project from Eclipse to Android Studio (I do not fully control this IDE yet). In this project, I have a file uploader AsyncTask which send multipart over http. To do this, I use org.apache.httpcomponents. I created following dependencies: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'org.apache.httpcomponents:httpcore:4.4' compile 'org.apache.httpcomponents:httpmime:4.4' ... } In my java AsyncTask code: MultipartEntityBuilder builder =

How do you connect localhost in the Android emulator?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 12:50:59
I have made a php script inside localhost and I am connecting that with httpClient but I am getting a problem. Please tell me how can I connect to a php file at localhost from the emulator? lampShaded Use 10.0.2.2 to access your actual machine. As you've learned, when you use the emulator, localhost ( 127.0.0.1 ) refers to the device's own loopback service, not the one on your machine as you may expect. You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development. Use 10.0.2.2 for default AVD and 10.0.3.2 for Genymotion Instead of giving localhost give the

Getting NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser

我是研究僧i 提交于 2019-11-26 07:33:40
问题 I\'m working on an app on Android. I\'m using httpcore 4.3.3. I get this when I try to use ContentType.parse(string) java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueParser; in class Lorg/apache/http/message/BasicHeaderValueParser; or its superclasses (declaration of \'org.apache.http.message.BasicHeaderValueParser\' appears in /system/framework/ext.jar) I\'ve done some googling and I understand why I\'m getting the error, but I\'m unsure

How do you connect localhost in the Android emulator?

落花浮王杯 提交于 2019-11-26 03:33:29
问题 I have made a php script inside localhost and I am connecting that with httpClient but I am getting a problem. Please tell me how can I connect to a php file at localhost from the emulator? 回答1: Use 10.0.2.2 to access your actual machine. As you've learned, when you use the emulator, localhost ( 127.0.0.1 ) refers to the device's own loopback service, not the one on your machine as you may expect. You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development

POST Multipart Form Data using Retrofit 2.0 including image

空扰寡人 提交于 2019-11-26 01:26:42
问题 I am trying to do a HTTP POST to server using Retrofit 2.0 MediaType MEDIA_TYPE_TEXT = MediaType.parse(\"text/plain\"); MediaType MEDIA_TYPE_IMAGE = MediaType.parse(\"image/*\"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); imageBitmap.compress(Bitmap.CompressFormat.JPEG,90,byteArrayOutputStream); profilePictureByte = byteArrayOutputStream.toByteArray(); Call<APIResults> call = ServiceAPI.updateProfile( RequestBody.create(MEDIA_TYPE_TEXT, emailString),

Make an HTTP request with android

痴心易碎 提交于 2019-11-25 22:19:12
问题 I have searched everywhere but I couldn\'t find my answer, is there a way to make an simple HTTP request? I want to request an PHP page / script on one of my website but I don\'t want to show the webpage. If possible I even want to do it in the background (in an BroadcastReceiver) 回答1: UPDATE This is a very old answer. I definitely won't recommend Apache's client anymore. Instead use either: OkHttp HttpUrlConnection Original Answer First of all, request a permission to access network, add