okhttp

not able to import com.squareup.okhttp.OkHttpClient;

南笙酒味 提交于 2019-12-28 21:54:30
问题 I am working on android studio and fetching some data from the web. I tried using OkHttpClient and also added jars to my project folder but still i am unable to import it. It shows can't resolve symbol okhttp . I tried some solution but unable to solve the problem.Here is my build.gradle file apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.0" defaultConfig { applicationId "com.example.app" minSdkVersion 14 targetSdkVersion 23 versionCode 1

Retrofit Uploading multiple images to a single key

随声附和 提交于 2019-12-28 01:48:11
问题 I am using Retrofit to upload images to my server. Here I need to upload multiple images for a single key. I have tried with Postman web client it is working well. Here is a screenshot. Here are the key value pairs for the request. SurveyImage : [file1,file2,file3]; PropertyImage : file DRA : jsonBody I tried to do the same with Retrofit. but the images are not uploading to the server.Here is my code. WebServicesAPI.java public interface WebServicesAPI { @Multipart @POST(WebServices.UPLOAD

Retrofit 2 OkHttpClient caching not working

妖精的绣舞 提交于 2019-12-25 18:53:52
问题 So here's the problem, I'm trying to implement caching for my app and I followed this tutorial Android: Cache network requests for offline access with Retrofit2 and OkHTTP3 to do it. Sadly, cached responses are not showing up when there is no internet connection, instead the Toast.makeText(getContext(), getContext().getResources().getString(R.string.error_failed_to_load_posts), Toast.LENGTH_SHORT).show(); gets executed. So can anyone tell me what I am doing wrong? Or guide me to get an answer

Azure Event Hub Authorization from Android

前提是你 提交于 2019-12-25 07:50:03
问题 I‘m working on an application that sends data to an azure event hub. This is similar to the blog post here:http://sreesharp.com/send-events-from-android-app-to-microsoft-azure-event-hubs/ However, I updated the connection code to use OkHttp: public void sendMessageOkHttp(String dataPacket, String connectionString, String sasKey){ // Instantiate the OkHttp Client OkHttpClient client = new OkHttpClient(); // Create the body of the message to be send RequestBody formBody = new FormBody.Builder()

How can I make some class, running in the Main Thread, await concurrently for other class to reach some specific state?

僤鯓⒐⒋嵵緔 提交于 2019-12-25 04:14:39
问题 I am having serious difficulties to understand how can I make some AsyncTask children, declared and instantiated in the Main Thread, to await for a Service child instance to reach some specific state. As code examples here is the relevant part for Service; this code does what expected: receives the JSON response and holds it. public class MyService extends Service { private boolean received = false; private string url = "http://someserver.mine/get-data-in-json-format"; // [...] @Override

Retrofit with OkHTTP not set Content-Type with @FormUrlEncoded

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 03:36:08
问题 I'm trying to implement auth via x-www-form-urlencoded with Retrofit 2 on Android but faced a problem, that Header Content-Type not set with @FormUrlEncoded annotation, as well as I'm trying to set it manually, but when I'm setting it with a typo like Cotent-Type it works correctly and I can see it in headers. Retrofit version: 2.4.0 So my question: why @FormUrlEncoded not set a content type as well as @Header annotation or what can remove it from headers. My request: @FormUrlEncoded @POST(

Global state and local address in OkHttp

☆樱花仙子☆ 提交于 2019-12-24 16:56:21
问题 We are currently using Apache Httpclient in our custom load test framework. I have to implement support for WebSocket testing, and since HttpClient does not support WebSockets, I am looking for alternatives. So, I've been playing with OkHttp and Async Http Client. In general, I could use both as a replacement, but either one gives me a few challenges I need to tackle. Here's the ones I'm facing with OkHttp: OkHttp uses global static state in com.squareup.okhttp.internal.Internal which seems a

Global state and local address in OkHttp

柔情痞子 提交于 2019-12-24 16:55:12
问题 We are currently using Apache Httpclient in our custom load test framework. I have to implement support for WebSocket testing, and since HttpClient does not support WebSockets, I am looking for alternatives. So, I've been playing with OkHttp and Async Http Client. In general, I could use both as a replacement, but either one gives me a few challenges I need to tackle. Here's the ones I'm facing with OkHttp: OkHttp uses global static state in com.squareup.okhttp.internal.Internal which seems a

Picasso and OkHttp

时光总嘲笑我的痴心妄想 提交于 2019-12-24 16:15:24
问题 A question about a thing that I don't understand: does Picasso use OkHttp as default downloader, or should I configure it by myself? And - if not - why should I use Picasso with OkHttp ? What are the advantages compared to the default Picasso ? Thanks. (currently I'm using Picasso v.2.5.2 ) 回答1: If OkHttp is available in your project, Picasso will use it. If not, Picasso will fall back to HttpUrlConnection . 来源: https://stackoverflow.com/questions/32143949/picasso-and-okhttp

How to close http client connection after getting the response?

 ̄綄美尐妖づ 提交于 2019-12-24 09:49:32
问题 I am using http client to send a request. I want to make sure I am closing the connection after the response is received. code: public class WebserviceCall extends AsyncTask<Void,Void,String> { // interface for response AsyncResponse delegate; private final MediaType URLENCODE = MediaType.parse("application/json;charset=utf-8"); ProgressDialog dialog; Context context; String dialogMessage; boolean showDialog = true; String URL; String jsonBody; private OkHttpClient client; public