java - OkHttp in android for making network requests -


What am I trying to do? ::

I try

What did I do ::

  • I have read their document
  • I did the project I have downloaded and added JR
  • I use my sample code

    from MyCode :

    Main activity. Java

      Import android.app.Activity; Importroid.os.Bundle; Import android.util.log; Import com.squareup.okhttp.OkHttpClient; Import com.squareup.okhttp.internal.http.Request; Import com.squareup.okhttp.internal.http.Response; Public class increases main activity activity {@ Override Protected Zero to Create (Bundle Saved Instantstate) {Super.New (Saved Instantstate); SetContentView (R.layout.activity_main); Request request = new request the creator (). Url ("https://raw.github.com/square/okhttp/master/README.md") .build (); Feedback feedback = client.execute (request); Log D. ("Answer", reaction.boo (). String ()); }}   

    is facing an error ::

    in line response = client.execute (request ); I am getting the error like this:

    The customer can not be resolved in a variable

    How to solve it! >

    {update}
      Expands public class main activity (OKHTP Client Client = New OKHTP Client (); @ Override Protected Zero (Creates Bundle InstantState) {Super .Net (savedinstenstate); setContentView (R.layout.activity_main); request request = new request.bilder () .url ("https://raw.github.com/square/okhttp/master/README.md" ) .build (); Response feedback = client.execute (request); Log D. ("Answer", reaction.bio (). String ());}}   

    Now I am facing the error:

    line feedback feedback = client Execute (request); as the method execution (request) type OkHttpClient

    is undefined for

    The method executed (request) is required for OkHttpClient

    You are receiving this exception because no such method . for execute (request ) OkHttpClient . Instead, it is applied to the call object, which is achieved by using the OkHttpClient object as follows:

      call calls = Client.NewColl (request); Feedback response = call.execute ();   

    I think you should use

      feedback feedback = client.newCall (request). Execute ();  Response = instead of client.execute (request)   



Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -