Android Question Trying to make sense of java.lang.ClassCastException on CustomListView Item Click event

ema01

Member
Licensed User
Longtime User
Hello,
i'm trying to understand why this would happen.
Of course it never happens on our devices, in fact, i don't understand why according to vitals customer devices are full of nullpointer exceptions.
Anyway, I have a CLV which is populated with objects, the objects are all the same and of course they are initialized.
As a matter of fact, the objects are stored in a list owned by a foreground service, so i may want to assume that they are never destroyed by the OS
However, since last update i've had a spike of ClassCastException and i can't find a reason for it.
Could you help me with some pointers?
 

aeric

Expert
Licensed User
Longtime User
No.
Why would that even make a difference?
Read about it to understand.
I think Android life cycle, screen rotation causes activity restart and variables leverage between different activities may cause issue to the null object exception.
These maybe solved using B4XPages.
 
Upvote 0

ema01

Member
Licensed User
Longtime User
I have actually been doing B4X Pages before they were even made (i just always designed my apps that way.)
How does that would apply to the problem at hand?
* Foreground Service contains a list of objects.
* For each element in the list a CustomListView is populated, the value of the item is the list element (so since it's a class, a reference to the item)
* The CLV is populated when it's created, or when the list changes so the content is always "fresh"
* User clicks on element of the list, there are two cases in which the ClassCastException could happen
1) The panel somehow forgets its layout and the zeroth view in it (the only view in it - I change the label font) is not a label anymore. What?????
2) I assign value to an object of the same type of the list element. But this means that value doesn't point to that object type anymore. What??????
The way the application is designed, the list and the CLV can not change if the user is able to interact with them
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
No point to write so much to explain. The community is unable to help with these information.
Check how to post a question.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I am not 100% sure but it seems your assumptions above are wrong.
You can't expect the OS doen't clear your object.
Noone is sitting in front your screen or your mind to know exactly your code and error logs without you posting any of them.
To help yourself, you need to help members understand your problem which what you provided are insufficient.
Try ask AI, if you could have better luck with your "well explanation".
 
Upvote 0
Top