我的应用程序在棉花糖上工作得非常好,但自从牛轧糖更新后,MainActivity就无法启动了。它不会给我任何错误,只是在启动应用程序时看到的空白屏幕。
修改 我设法将原因减少到MainActivity中的一小段代码,该代码在onCreate函数中运行:
if((parsedCijferString.isEmpty()) && (parsedHuiswerkString.isEmpty())){
mViewPager.setCurrentItem(1);
String cijferString;
String roosterString;
String huiswerkString;
try {
cijferString = dataGetterC.getData(som.getGradesUrl());
parsedCijferString = cijfers.ParseJSON(cijferString);
roosterString = dataGetterR.getData(som.getTimetableUrl(System.currentTimeMillis()));
parsedRoosterString = rooster.ParseJSON(roosterString);
huiswerkString = dataGetterH.getData(som.getHomeworkUrl(14));
parsedHuiswerkString = huiswerk.ParseJSON(huiswerkString);
} catch (Exception e) {
e.printStackTrace();
}
}
问题是三个块中只有一个(“cijferString”,“roosterString”,“huiswerkString”)能够运行,所以如果我禁用其他两个块它将会运行,但是当我将它们全部启用时不会。 这三个块使用另一个名为DataGetter的类,我通过okHttp获取数据:
DataGetter:
package com.bettersomtoday.arnedebeer.somtoday;
import android.util.Log;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
class DataGetter {
private String responseString;
private final OkHttpClient client = new OkHttpClient();
String getData(String url) throws Exception {
Request request = new Request.Builder()
.url(url)
.build();
client.newCall(request).enqueue(new Callback() {
@Override public void onFailure(Call call, IOException e) {
e.printStackTrace();
Log.i("REQUEST","FAIL");
responseString = "FAIL";
}
@Override public void onResponse(Call call, Response response) throws IOException {
responseString = response.body().string();
Log.i("Response datagetter", responseString);
}
});
//noinspection StatementWithEmptyBody
while (responseString == null){
//Do nothing
}
return responseString;
}
}
希望这可能会清除一些事情!
END OF EDIT
我真的不知道要提供什么信息,所以请随时问!现在我会给你一些可能与这个问题有关的信息。