The key issue I have is doing lv_apps.setAdapter(_adapter) TWICE is what crashes my app. (Basically, when i call populateListView_trial() the 2nd time, app crashes -- and the offending line is lv_apps.setAdapter(_adapter)
Stacktrace is below the functions
private void populateListView_trial() {
blockedApps = loadArrayBlockedApps();
if(isTimerRunning()) {
blockedApps = loadArrayBlockedApps();
temp_blockedList = new ArrayAdapter<String>(
MainActivityCircularSeekbar.this,
android.R.layout.simple_list_item_1, blockedApps);
} else {
holder = new ArrayList<Datamodel>();
for(Map.Entry<String, String> entry : list_installedApps.entrySet()) {
Datamodel _appdata = new Datamodel();
_appdata.setAppname(entry.getKey());
_appdata.setSelected(true);
try {
_appdata.setAppIcon(getIconFromPackageName(entry.getValue(), this));
} catch (Exception e) {
e.printStackTrace();
} catch (OutOfMemoryError e) {
e.printStackTrace();
}
holder.add(_appdata);
}
_adapter = new MyAdapter(getApplicationContext(), holder);
try {
lv_apps.setAdapter(_adapter);
} catch (Exception e) {
Log.v(TAG_debug, " caught exception in line 2097, STACKTRACE =");
}
}
}
@SuppressWarnings("null")
private Map<String, String> getInstalledAppsList() {
List<String> l_installedApps = new ArrayList<String>();
//List<Map<String, String>> map_installedApps = new ArrayList<Map<String, String>>();
Map<String, String> map_installedApps = new HashMap<String, String>();
List<PackageInfo> allPackagesList = getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA);
PackageManager pm = getPackageManager();
for(int i = 0 ; i < allPackagesList.size() ; i++) {
PackageInfo p = allPackagesList.get(i);
String appname = p.applicationInfo.loadLabel(pm).toString();
String packageName = p.packageName;
map_installedApps.put(appname, packageName);
//l_installedApps.add(appname);
}
return map_installedApps;
}
Offending line: 05-26 22:35:44.304: E/AndroidRuntime(4168): java.lang.IllegalStateException: Observer android.widget.AbsListView$AdapterDataSetObserver@529347d0 was not registered.
How can i get around this??? I need to update various elements in the listview.
05-26 22:35:40.408: E/OpenGLRenderer(4168): Getting MAX_TEXTURE_SIZE from GradienCache
05-26 22:35:40.412: E/OpenGLRenderer(4168): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
05-26 22:35:44.304: E/AndroidRuntime(4168): FATAL EXCEPTION: main
05-26 22:35:44.304: E/AndroidRuntime(4168): java.lang.IllegalStateException: Observer android.widget.AbsListView$AdapterDataSetObserver@529347d0 was not registered.
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.database.Observable.unregisterObserver(Observable.java:69)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.widget.BaseAdapter.unregisterDataSetObserver(BaseAdapter.java:42)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2638)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.view.View.dispatchDetachedFromWindow(View.java:12160)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2570)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2568)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:3960)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.view.ViewGroup.removeAllViews(ViewGroup.java:3904)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.widget.TabHost.clearAllTabs(TabHost.java:251)
05-26 22:35:44.304: E/AndroidRuntime(4168): at com.mavdev.focusoutfacebook.MainActivityCircularSeekbar$LoadALLAppsList.onPostExecute(MainActivityCircularSeekbar.java:2480)
05-26 22:35:44.304: E/AndroidRuntime(4168): at com.mavdev.focusoutfacebook.MainActivityCircularSeekbar$LoadALLAppsList.onPostExecute(MainActivityCircularSeekbar.java:1)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.os.AsyncTask.finish(AsyncTask.java:631)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.os.Handler.dispatchMessage(Handler.java:99)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.os.Looper.loop(Looper.java:137)
05-26 22:35:44.304: E/AndroidRuntime(4168): at android.app.ActivityThread.main(ActivityThread.java:5103)
05-26 22:35:44.304: E/AndroidRuntime(4168): at java.lang.reflect.Method.invokeNative(Native Method)
05-26 22:35:44.304: E/AndroidRuntime(4168): at java.lang.reflect.Method.invoke(Method.java:525)
05-26 22:35:44.304: E/AndroidRuntime(4168): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-26 22:35:44.304: E/AndroidRuntime(4168): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-26 22:35:44.304: E/AndroidRuntime(4168): at dalvik.system.NativeStart.main(Native Method)
05-26 22:36:56.648: E/OpenGLRenderer(4237): Getting MAX_TEXTURE_SIZE from GradienCache
05-26 22:36:56.656: E/OpenGLRenderer(4237): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
05-26 22:37:00.256: E/AndroidRuntime(4237): FATAL EXCEPTION: main
05-26 22:37:00.256: E/AndroidRuntime(4237): java.lang.IllegalStateException: Observer android.widget.AbsListView$AdapterDataSetObserver@529379f0 was not registered.
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.database.Observable.unregisterObserver(Observable.java:69)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.widget.BaseAdapter.unregisterDataSetObserver(BaseAdapter.java:42)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2638)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.view.View.dispatchDetachedFromWindow(View.java:12160)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2570)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2568)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:3960)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.view.ViewGroup.removeAllViews(ViewGroup.java:3904)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.widget.TabHost.clearAllTabs(TabHost.java:251)
05-26 22:37:00.256: E/AndroidRuntime(4237): at com.mavdev.focusoutfacebook.MainActivityCircularSeekbar$LoadALLAppsList.onPostExecute(MainActivityCircularSeekbar.java:2480)
05-26 22:37:00.256: E/AndroidRuntime(4237): at com.mavdev.focusoutfacebook.MainActivityCircularSeekbar$LoadALLAppsList.onPostExecute(MainActivityCircularSeekbar.java:1)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.os.AsyncTask.finish(AsyncTask.java:631)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.os.Handler.dispatchMessage(Handler.java:99)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.os.Looper.loop(Looper.java:137)
05-26 22:37:00.256: E/AndroidRuntime(4237): at android.app.ActivityThread.main(ActivityThread.java:5103)
05-26 22:37:00.256: E/AndroidRuntime(4237): at java.lang.reflect.Method.invokeNative(Native Method)
05-26 22:37:00.256: E/AndroidRuntime(4237): at java.lang.reflect.Method.invoke(Method.java:525)
05-26 22:37:00.256: E/AndroidRuntime(4237): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-26 22:37:00.256: E/AndroidRuntime(4237): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-26 22:37:00.256: E/AndroidRuntime(4237): at dalvik.system.NativeStart.main(Native Method)
AsyncTask
in the code. Please post the exact code. Or the correct stacktrace. – Leasia