retrofit2

Android - Retrofit2 - java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

烈酒焚心 提交于 2020-01-05 05:41:09
问题 I want to get data from the server (https://data.egov.kz/api/v2/zheke_zhane_zandy_tulgalardy_k1/v6?pretty) as an array of json objects. But I get this Log: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. I am using Retrofit2 and here my code: MainActivity.java public class MainActivity extends AppCompatActivity implements GetAdmissionSchedule.GetAdmissionScheduleInterface { @Override protected void onCreate(Bundle savedInstanceState) { super

Recyclerview Search Filter not working android

核能气质少年 提交于 2020-01-05 03:57:05
问题 My title is coming from retrofit.when I type anything in searchview it doesnt show any result/Suggestion when typed. here is the ss ---> enter image description here im referring this blog --> https://velmm.com/android-recyclerview-search-filter-example/ help will be appreciated...thanks in advance Search activity: public class Search extends AppCompatActivity { SearchView searchView; RecyclerView recyclerView; SearchAdapter slAdapter; List<StartLearning.SlModel> movieList; @Override

onNext() onError() callbacks not executing on second subscribtion android

旧巷老猫 提交于 2020-01-05 03:55:07
问题 I've an Observable something like this: @GET("endpoint") Observable<Something> getSomething(); and Subscriber like this Subscriber<Something> somethingSubscriber = new Subscriber<Something>() { public void onCompleted() { } public void onError(Throwable e) { //handle exceptions } public void onNext() { //do something } In my OnClickListener associated with a button, i make a subscription getSomething() .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe

Getting socket.io response in android client, but can't understand how to implement the response in recycler adapter

冷暖自知 提交于 2020-01-05 02:09:32
问题 I'm working on a real-time chatting android application where I need to connect socket.io for real-time response. I followed this tutorial:https://socket.io/blog/native-socket-io-and-android/ and I've successfully implemented socket.io in my android app and getting the response in a toast. Here is the Socket connection class: import android.app.Application; import java.net.URISyntaxException; import io.socket.client.IO; import io.socket.client.Socket; public class ChatApplication extends

Android connection with ESP8266 on One Plus ( Android 6.0.1)

≯℡__Kan透↙ 提交于 2020-01-04 09:36:35
问题 Retrofit on Android 6.0 has a problem making Http calls after connecting to Access Point Steps to reproduce: Connect to Esp8266 Access Point Make an http call to http://192.168.4.1 (Default gateway of esp8266 accesspoint) The IP address of WIFI is 192.168.4.2 It throws the below exception I have tried the same on Android 5.1 and the same code works flawlessly java.net.SocketException: socket failed: ENONET (Machine is not on the network) at libcore.io.IoBridge.socket(IoBridge.java:619) at

Retrofit 2 error: NetworkOnMainThreadException

我与影子孤独终老i 提交于 2020-01-04 06:51:06
问题 I'm trying to do a synchronous request to my server in Android. (Code works flawlessly in a plain Java project) I know that sync requests shouldn't be done on the main thread, so I start a new thread where the networking is done. I also know that it is possible to do Async-calls but a sync call fits my usecase better. bool networkingIsDoneHere(){ dostuff(); int number = doNetworkCall(); if(number < 500){ return true; } return false } The problem is that I still get the

How to inject dependencies in ViewModels using Dagger2

自古美人都是妖i 提交于 2020-01-04 05:57:35
问题 I am trying to implement new architecture (MVVM + RxJava2 + Dagger2 + Retrofit) in my existing project. I have set up whole above architecture and tested on HomeActivity. Dependencies injected in HomeViewModel. So Now I was trying to inject dependencies same as HomeViewModel in a FollowingViewModel of FollowingFragment which is a container Fragment of HomeActivity.But injected dependencies always return null(Not Initiziling). I am following this project riggaroo/android-arch-components-date

Repeatedly make API call with retrofit and rxjava

馋奶兔 提交于 2020-01-04 03:59:34
问题 I have a retrofit observable: @GET("something/") Observable<Something> getSomething(); subscribing to it gives the response. getSomething().subscribe(new Subscriber<Something>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(Something something) { //update database of something } }); how can i make this call every 60 seconds so that i can update database accordingly? 回答1: First please don't do it if you can avoid it. It's

Retrofit2 Deserialize response body even if response is not 200

孤街浪徒 提交于 2020-01-03 19:16:22
问题 I want to be able to deserialize network response to the same Java object even if response is not succesfull. Currently when I get an error response like 403, the response body is null, and I'm expected to use the response.errorBody() method to read whatever has been sent back, which is ok. However I want to avoid having alot of code in the retrofit callbacks just for deserializing errorBody. Instead I want to have an interceptor that sets the content of errorBody into body. The reason for

retrofit Expected a string but was BEGIN_OBJECT at line 1 column 2 path $

若如初见. 提交于 2020-01-03 18:53:12
问题 I'm trying to get just string request but it's give error like this Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ And my API output is like this : { "status": true, "message": "Video uploaded successfully!", "data": { "video_name": "674631516178278_abc2.mp4", "video_thumbnail": "674631516178278_thumb0017.jpg" } } Code for response : @Override public void onResponse(Call<String> call, Response<String> response) { try { if (response.body() != null) Log.e("UploadResponse>>>