我的繼承人logcat的錯誤strace的Android的線程應用程序崩潰時,有沒有互聯網連接的
06-17 10:50:59.578: E/AndroidRuntime(1899): FATAL EXCEPTION: AsyncTask #1
06-17 10:50:59.578: E/AndroidRuntime(1899): java.lang.RuntimeException: An error occured while executing doInBackground()
06-17 10:50:59.578: E/AndroidRuntime(1899): at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-17 10:50:59.578: E/AndroidRuntime(1899): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-17 10:50:59.578: E/AndroidRuntime(1899): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-17 10:50:59.578: E/AndroidRuntime(1899): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-17 10:50:59.578: E/AndroidRuntime(1899): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-17 10:50:59.578: E/AndroidRuntime(1899): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-17 10:50:59.578: E/AndroidRuntime(1899): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-17 10:50:59.578: E/AndroidRuntime(1899): at java.lang.Thread.run(Thread.java:856)
06-17 10:50:59.578: E/AndroidRuntime(1899): Caused by: java.lang.NullPointerException
06-17 10:50:59.578: E/AndroidRuntime(1899): at com.merimasjid.prayertimes.hijri.FavouritePagePrayerTimes1$LoadTimes.doInBackground(FavouritePagePrayerTimes1.java:561)
06-17 10:50:59.578: E/AndroidRuntime(1899): at com.merimasjid.prayertimes.hijri.FavouritePagePrayerTimes1$LoadTimes.doInBackground(FavouritePagePrayerTimes1.java:1)
06-17 10:50:59.578: E/AndroidRuntime(1899): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-17 10:50:59.578: E/AndroidRuntime(1899): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-17 10:50:59.578: E/AndroidRuntime(1899): ... 4 more
我有,當應用程序啓動後自動執行單一線程並且此線程裏面片段定義。該線從互聯網上抓取一些JSON數據和diplays它在屏幕上,應用程序工作正常時,數據連接或無線網絡連接上,但在沒有分組數據的,它只是崩潰啓動時,應用程序
class LoadTimes extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
//pBar.setVisibility(View.VISIBLE);
}
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// params.add(new BasicNameValuePair("areaID","0"));
try{
params.add(new BasicNameValuePair("MasjidID",String.valueOf(_appPrefs.getFavOneID())));
params.add(new BasicNameValuePair("Date", getParameterisedDate()));
//params.add(new BasicNameValuePair("date",getParameterisedDate()));
}catch(Exception e){}
JSONObject json = null;
try{
json = jsonParser.makeHttpRequest(URL_GET_TIMES, "GET",
params);
}catch(Exception e){}
// Check your log cat for JSON response
Log.d("Outbox JSON: ", json.toString());
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
try {
albums = json.getJSONArray("masjids");
// looping through All messages
if(albums!=null){
for (int i = 0; i < albums.length(); i++) {
JSONObject c = albums.getJSONObject(i);
Date d1 = df.parse(c.getString("FajarAzan"));
SunrH = d1.getHours();
SunRM = d1.getMinutes();
Date d2 = df.parse(c.getString("FajarAzan"));
fajrH = d2.getHours();
fajrM = d2.getMinutes();
Date d3 = df.parse(c.getString("ZoharAzan"));
DhuhrH = d3.getHours();
DhuhrM = d3.getMinutes();
Date d4 = df.parse(c.getString("AsarAzan"));
AsrH = d4.getHours();
AsrM = d4.getMinutes();
Date d5 = df.parse(c.getString("Maghrib"));
MaghribH = d5.getHours();
MaghribM = d5.getMinutes();
Date d6 = df.parse(c.getString("IshaAzan"));
IshaH = d6.getHours();
IshaM = d6.getMinutes();
_appPrefs.storeFavouriteMasjidTimes(fajrH, fajrM, SunrH, SunRM, DhuhrH, DhuhrM, AsrH, AsrM, MaghribH, MaghribM, IshaH, IshaM, day, month, year, _appPrefs.getFavOneID());
try{
initNamazTimes();
}catch(Exception e){}
/*
namazTimesH = new int[]{fajrH,SunrH,DhuhrH,AsrH,MaghribH,IshaH};
namazTimesM = new int[]{fajrM,SunRM,DhuhrM,AsrM,MaghribM,IshaM};*/
}
}
} catch (Exception e) {
// pBar.setVisibility(View.GONE);
//
// cantGet = true;
publishProgress(null);
Log.e("Exception while Loading Times",e.toString());
}
return null;
}
@Override
public void onProgressUpdate(String... args) {
super.onProgressUpdate(args);
try{
FetchStoreFavouriteNamazTimings.cantGetNamazTimes();}catch(Exception e){}
}
protected void onPostExecute(String file_url) {
if(cantGet)
{
FetchStoreFavouriteNamazTimings.cantGet = false;
}
else{
try{
generateButtonsAlarms();
generateButtonsFavourites();}
catch(Exception e){}
/////////////////////////////////////////////////////////////////////
}
}
}
發佈崩潰日誌將有助於... – elmorabea