WinDeath on notifyDataSetChanged()
Hi I have following problem:
data.clear();
data.addAll(datasource.getFilesInFolder()); //gets the data from Sqlite database
adapter.notifyDataSetChanged();
generates this logCat output :
12-19 14:34:30.864: W/Binder(986): Caught a RuntimeException from the binder stub implementation.
12-19 14:34:30.864: W/Binder(986): java.lang.NullPointerException
12-19 14:34:30.864: W/Binder(986): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
12-19 14:34:30.864: W/Binder(986): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
12-19 14:34:30.864: W/Binder(986): at android.os.Binder.execTransact(Binder.java:404)
12-19 14:34:30.864: W/Binder(986): at dalvik.system.NativeStart.run(Native Method)
12-19 14:34:30.864: W/InputMethodManagerService(757): Got RemoteException sending setActive(false) notification to pid 30040 uid 10174
This exception causes WIN DEATH...
Well I realized maybe it is the other way round, WIN DEATH causing this log output, because in log WINDEATH comes before this, then I have no idea why does windeath occur.
My adapter is extended BaseAdapter with nothing really special in it. Very strange is the following :
The mentioned piece of code is inside a custom listener which is triggered from another class. When I put the problematic part outside the listener it works well.
I does the Caught a RuntimeException from the binder stub implementation
mean ? Can it be a problem with a database ? or maybe my custom listener ? Anyone has an idea what's wrong ?
I have seen various problems that have this issue when doing concurrent actions. See for instance this thread (fling + service) and this one (drawing on canvas from 2 threads).
You are talking about a custom listener in a different class, could it be that you are also doing several things at once?
You should add the data into adapter directly.
Instead of doing
data.clear();
data.addAll(datasource.getFilesInFolder()); //gets the data from Sqlite database
adapter.notifyDataSetChanged();
You should do
if(adapter!=null)
{
adapter.clear();
adapter.addAll(datasource.getFilesInFolder()); //gets the data from Sqlite database
adapter.notifyDataSetChanged();
}
I think the adapter is null which is causing the problem in your case
链接地址: http://www.djcxy.com/p/18106.html