android - Using TLS only with Retrofit in RoboSpice -


i've got basic setup using robospice retrofit in shell android application making rest calls, parsing json response pojo , can use render in activity. want use tls transport security (not ssl). i've read retrofit okhttp can used achieve don't know make update in code.

i have basic interface:

public interface randomapi {     @get("/users")     list<user> getusers(@path("owner") string owner, @path("repo") string repo);      @get("/users/{userid}")     user getuser(@path("userid") int userid); } 

i have service:

public class randomservice extends retrofitgsonspiceservice {  private final static string base_url = "http://jsonplaceholder.typicode.com";  @override public void oncreate() {     super.oncreate();     addretrofitinterface(randomapi.class); }  @override protected string getserverurl() {     return base_url; } } 

and request:

public class randomrequest extends retrofitspicerequest<user, randomapi> {  private int userid;  public randomrequest(int userid) {     super(user.class, randomapi.class);     this.userid = userid; }  @override public user loaddatafromnetwork() throws exception {     return getservice().getuser(userid); }  } 

i'm guessing need update service not sure how. simplicity of pattern keep if possible. can drop okhttp jars application don't know how @ actual implementation of service, or how add custom 1 requests use it.

has 1 had experience share code snippets or point me example?

~~ edit ~~

looking api robospice, looks request can extend spicerequest, within loadfromnetwork() method plain retrofit , okhttp stuff. way though? thought there way set own restadapter implementation in retrofitspiceservice instead of using default.

so quite simple. create class extends retrofitgsonspiceservice , override createrestadapterbuilder() method.

e.g.

@override protected builder createrestadapterbuilder() {     restadapter.builder builder = new restadapter.builder()         .setendpoint(service_url)         .setrequestinterceptor(requestinterceptor);     return builder;  } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -