Android Question CastClassException in searchView class in widget

henry1311

Member
Licensed User
Longtime User
I have an app that inserts data into a sqlite db and it is working well.
I modified it to make it work as a widget so that any changes in the values of some fields should be updated in an image and a label in the widget.
Some fields require the phone number that I withdraw from the contacts through class 'contactsUtils' and 'SearchView' (of erel).
Everything works fine. Every so often, however, updating the phone number, press the button to search for contacts, then calling the class 'SearchView', I get this error.
The error does not come out at regular intervals.
If I turn off and on the smartphone the error always comes out and you can not log in anymore except by reinstalling the app/widget.

LogCat connected to: B4A-Bridge: LGE LG-P500-354043041226012
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
<!>anywheresoftware.b4a.BA 474<!> ~i:** Service (widgetservice) Start **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actmenu) Create, isFirst = true **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actmenu) Resume **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actmenu) Pause, UserClosed = false **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actcard) Create, isFirst = true **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actcard) Resume **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actcard) Pause, UserClosed = true **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actmenu) Resume **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actmenu) Pause, UserClosed = false **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actcard) Create, isFirst = false **
<!>anywheresoftware.b4a.BA 474<!> ~i:** Activity (actcard) Resume **
<!>anywheresoftware.b4a.BA 474<!> ~e:searchview_setindex (java line: 225)
<!>anywheresoftware.b4a.BA 474<!> ~e:java.lang.ClassCastException: java.lang.Object
at app.dm.icewidget.searchview._setindex(searchview.java:225)
at app.dm.icewidget.actcard._selcontacts(actcard.java:975)
at app.dm.icewidget.actcard._btncall2_click(actcard.java:684)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:63)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3729)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
at dalvik.system.NativeStart.main(Native Method)


Line 225 in searchview class is this :
224 //BA.debugLineNum = 125;BA.debugLine="obj = Index";
225 _obj = (Object[])(_index);

Thanks for the help
Enrico
 

henry1311

Member
Licensed User
Longtime User
If you use the example of Erel for searching for contacts using the class SearchView and you are also using the Phone library, you must declare a variable other Contacts and consequently change it in the Main mod :

B4X:
Dim Contacts1 As List  '  NOT  Dim Contacts As List

Everything works correctly.

Thank you all for the help
Enrico
 
Upvote 0
Top