Android 原因:GsaIOException:错误代码:393238 |缓冲区溢出,没有可用空间
在这里,我有两个活动,带有某些按钮的活动a和一个活动B。当单击活动a上的某些按钮时,将出现活动B。在Activity_b中,我尝试使用获取JSON_对象,并在recyclerview中显示数据 这是第一次一切顺利,在单击活动a中的某个按钮后,活动b出现在recyclerView中,其中包含数据列表。但是,如果我从活动_B按后退键,然后再次尝试单击活动_a的某个按钮,屏幕将保持黑色,并显示以下错误 原因:com.google.android.apps.gsa.shared.exception.GsaIOException: 错误代码:393238 |缓冲区溢出,没有可用空间。 这个有线问题浪费了我整整一天的时间,如果有人之前遇到过同样的问题或对此有任何想法,请帮助我 活动\u A.javaAndroid 原因:GsaIOException:错误代码:393238 |缓冲区溢出,没有可用空间,android,performance,memory-leaks,out-of-memory,retrofit2,Android,Performance,Memory Leaks,Out Of Memory,Retrofit2,在这里,我有两个活动,带有某些按钮的活动a和一个活动B。当单击活动a上的某些按钮时,将出现活动B。在Activity_b中,我尝试使用获取JSON_对象,并在recyclerview中显示数据 这是第一次一切顺利,在单击活动a中的某个按钮后,活动b出现在recyclerView中,其中包含数据列表。但是,如果我从活动_B按后退键,然后再次尝试单击活动_a的某个按钮,屏幕将保持黑色,并显示以下错误 原因:com.google.android.apps.gsa.shared.exception.Gs
@Override
public void onClick(View view) {
if (view.getId() == R.id.fab) {
Intent activityIntent = new Intent(this, Activity_B.class);
startActivity(activityIntent);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
toolbarAndViewInitialization();
/** Create handle for the RetrofitInstance interface*/
GetMessageDataService service = RetrofitInstance.getRetrofitInstance().create(GetMessageDataService.class);
/** Call the method with parameter in the interface to get the notice data*/
Call<MessageList> call = service.getMessageData();
/**Log the URL called*/
Log.wtf("URL Called", call.request().url() + "");
materialDialog.show();
call.enqueue(new Callback<MessageList>() {
@Override
public void onResponse(Call<MessageList> call, Response<MessageList> response) {
ArrayList<Message> noticeList = response.body().getMessageArrayList();
initDataToRecyclerView(noticeList);
materialDialog.hide();
}
@Override
public void onFailure(Call<MessageList> call, Throwable t) {
Toast.makeText(MessageActivity.this, "Something went wrong...Error message: " + t.getMessage(), Toast.LENGTH_SHORT).show();
materialDialog.hide();
}
});
}
public class RetrofitInstance {
private static Retrofit retrofit;
private static final String BASE_URL2 = "https://someurl.com/";
/**
* Create an instance of Retrofit object
*/
public static Retrofit getRetrofitInstance() {
retrofit = new Retrofit.Builder()
.baseUrl(ApisUtils.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
public static Retrofit getRetrofitInstance2() {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL2)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
}
活动_B.java
@Override
public void onClick(View view) {
if (view.getId() == R.id.fab) {
Intent activityIntent = new Intent(this, Activity_B.class);
startActivity(activityIntent);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
toolbarAndViewInitialization();
/** Create handle for the RetrofitInstance interface*/
GetMessageDataService service = RetrofitInstance.getRetrofitInstance().create(GetMessageDataService.class);
/** Call the method with parameter in the interface to get the notice data*/
Call<MessageList> call = service.getMessageData();
/**Log the URL called*/
Log.wtf("URL Called", call.request().url() + "");
materialDialog.show();
call.enqueue(new Callback<MessageList>() {
@Override
public void onResponse(Call<MessageList> call, Response<MessageList> response) {
ArrayList<Message> noticeList = response.body().getMessageArrayList();
initDataToRecyclerView(noticeList);
materialDialog.hide();
}
@Override
public void onFailure(Call<MessageList> call, Throwable t) {
Toast.makeText(MessageActivity.this, "Something went wrong...Error message: " + t.getMessage(), Toast.LENGTH_SHORT).show();
materialDialog.hide();
}
});
}
public class RetrofitInstance {
private static Retrofit retrofit;
private static final String BASE_URL2 = "https://someurl.com/";
/**
* Create an instance of Retrofit object
*/
public static Retrofit getRetrofitInstance() {
retrofit = new Retrofit.Builder()
.baseUrl(ApisUtils.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
public static Retrofit getRetrofitInstance2() {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL2)
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
}
问题已解决强>
在我的例子中,这个问题是由于循环中的愚蠢错误引起的。甚至在按下“后退”按钮后,循环将继续将数据放入数组列表并增加内存缓冲区大小。问题已解决强> 在我的例子中,这个问题是由于循环中的愚蠢错误引起的。甚至在按下“后退”按钮后,循环也会继续将数据放入数组_列表并增加内存缓冲区大小