سلام دوستان
نمیدونم چرا من هرکاری میکنم نمیتونم با این کتابخانه اطلاعات رو بخونم!
دستورات MainActivity
public class MainActivity extends AppCompatActivity {
private static MyApi myApi;
private static Retrofit retrofit;
final String BASE_URL = "https://jsonplaceholder.typicode.com";
TextView txt_json;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt_json = findViewById(R.id.txt_json);
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create() )
.build();
myApi = retrofit.create(MyApi.class);
Call<List<Post>> call = myApi.getPosts();
Callback<List<Post>> callback = new Callback<List<Post>>() {
@Override
public void onResponse( Call<List<Post>> call,
Response<List<Post>> response) {
if(response.isSuccessful()){
List<Post> posts = response.body();
}
}
@Override
public void onFailure(Call<List<Post>> call, Throwable t) {
txt_json.setText("خطا");
}
};
call.enqueue(callback);
}
}
دستورات MyApi
public interface MyApi {
@GET("/posts")
Call<List<Post>> getPosts();
}
دستوراتPost
public class Post {
@SerializedName("userId")
@Expose
private Integer userId;
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("title")
@Expose
private String title;
@SerializedName("body")
@Expose
private String body;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}
اپلیکشن که اجرا میشه فقط مینویسه خطا!!
اینم تصویری از لاگ :
http://s9.picofile.com/file/83284444..._05_200407.jpg
که همانطور که میبنید خطای
failed to make and chown /acct/uid_10060: Read-only file system رو میده !