Last active
May 27, 2019 11:23
-
-
Save nikunjparadva/48b96d0aad034f2349c9c6af3783dc8e to your computer and use it in GitHub Desktop.
Stackoverflow issue :- https://stackoverflow.com/a/56321583/5773037
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package paradva.nikss.test; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.widget.Toast; | |
import java.util.List; | |
import retrofit2.Call; | |
import retrofit2.Callback; | |
import retrofit2.Response; | |
import retrofit2.Retrofit; | |
import retrofit2.converter.gson.GsonConverterFactory; | |
import retrofit2.http.GET; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
fetch_information(); | |
} | |
public static String Base_URL ; | |
public static Retrofit retrofit; | |
public static Retrofit getApiClient() | |
{ | |
if (retrofit == null) | |
{ | |
Base_URL ="https://xenzet.com/GameCheat/"; | |
retrofit = new Retrofit.Builder().baseUrl(Base_URL) | |
.addConverterFactory(GsonConverterFactory.create()).build(); | |
} | |
return retrofit; | |
} | |
public interface Api { | |
@GET("viewgamesjson.php") | |
Call<List<Games>> GetGames(); | |
} | |
public void fetch_information() { | |
Api api = getApiClient().create(Api.class); | |
Call<List<Games>> call = api.GetGames(); | |
call.enqueue(new Callback<List<Games>>() { | |
@Override | |
public void onResponse(Call<List<Games>> call, Response<List<Games>> response) { | |
if(response.isSuccessful()) { | |
Log.e("onResponse", "onResponse: "+response.body() ); | |
} | |
} | |
@Override | |
public void onFailure(Call<List<Games>> call, Throwable t) { | |
Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); | |
} | |
}); | |
} | |
} |
i applied your code from here in my app and this was response i got.
yes that was responce in object mode, for converting in String formate
add this one in Games pojo
@Override public String toString() { return "Games{" + "gameid='" + gameid + '\'' + ", gameIcon='" + gameIcon + '\'' + ", gamesName='" + gamesName + '\'' + '}'; }
now you need to pass this list to recylerview adapter and show in the recylerview
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my response was this onResponse: [com.example.quizgames.Games@75ee120, com.example.quizgames.Games@abdcad9, com.example.quizgames.Games@373ac9e, com.example.quizgames.Games@70cd37f, com.example.quizgames.Games@c20ef4c, com.example.quizgames.Games@3b73b95, com.example.quizgames.Games@369f4aa]
what this suppose to mean