[英]How can I get request url from retrofit with rx ? - Android
MinSdkVersion
of my application is 17
and targetSdkVersion
is 25
.In this application I am connecting to service with Rx and retrofit, this code don't work on api 17
I can't connect to webService
, bellow is my code : MinSdkVersion
我申请的是17
和targetSdkVersion
是25
。在这个应用我连接,其中Rx和改造维修,这段代码不上工作api 17
我无法连接到webService
,波纹管是我的代码:
My RetrofitApi.java
: 我的
RetrofitApi.java
:
public class RetrofitApi {
private static PublicApi retrofit = null;
public static PublicApi getClient(String url) {
retrofit = new Retrofit.Builder()
.baseUrl(url)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build().create(PublicApi.class);
return retrofit;
}
}
My PublicApi.java
: 我的
PublicApi.java
:
public interface PublicApi {
@GET("/web_service/mobile/rest")
Observable<LastNews> lastNews(@Query("function") String function);
}
And : 和:
PublicApi publicApi = RetrofitApi.getClient("https://xxx.xxx.xxx/");
CompositeDisposable mCompositeDisposable = new CompositeDisposable();
mCompositeDisposable.add(publicApi.lastNews("getLastNews")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(this::responseLastNews, this::errorLastNews));
private void responseLastNews(LastNews lastNewses){
}
private void errorLastNews(Throwable error) {
Log.i("LOG", error.getMessage());
}
When I tested on API 17
get me error and don't connect to server.Told me : 当我在
API 17
上进行测试时,收到错误消息并无法连接到服务器。告诉我:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.