Updating ListView from BroadcastReciever - nullpointerexception
I have a BroadcastReceiver which creates a notification at a set time.
When the notification is created, I would like to update my ListView. I
realise I will only be able to do this is the app is running - this is
fine.
So, in my BroadcastReceiver I do this:
PendingFragment.getInstance().updateTheList();
Then in PendingFragment there is the getInstance() method and the
updateTheList() method.
private static PendingFragment instance;
public static PendingFragment getInstance() {
if (null == instance) {
instance = new PendingFragment();
}
return instance;
}
and
public void updateTheList() {
simpleAdpt.refreshMyAdapter();
}
The refreshMyAdapter() is a sub class of a custom adapter. All it does is
remove some items and then calls simpleAdpt.notifyDataSetChanged();
My problem is that I have a nullpointerexception in updateTheList() which
presumably means that simpleAdpt is null. I don't know why as I have that
ListView viewable on the screen with items in it - so how can it be null?
No comments:
Post a Comment