Android Question Object converted to string warning in B4A 8.80 Beta.

asales

Expert
Licensed User
Longtime User
I use this library and example from @DonManfred in B4A 8.50 and works fine:
https://www.b4x.com/android/forum/threads/add-your-own-stickerpack-to-whatsapp-sticker4w.99555/

I test the same example in B4A 8.80 Beta and I get this warning:
" Object converted to string. This is probably a programming mistake. "

in the line of the Log in this code:
B4X:
contparser.Initialize("")
Dim instr As InputStream
instr = File.OpenInput(File.DirAssets, "contents.json")
Log(contparser.parseStickerPacks(instr))  '<-- HERE
Why this in the new version?
I need to do something with this code?
 

DonManfred

Expert
Licensed User
Longtime User
I need to do something with this code?
No. You just do not need it...

It is written at a time i was in investigation on how it works, whether i need to wrap more or not... I found out that we do NOT need it at all. the logic is in the java-code.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Log(contparser.parseStickerPacks(instr)) '<-- HERE
the result is not really a string. But as we are using it in the LOG() it is converted to a String.
that´s the reason for the warning.

Edit to add: i don´t think it is related to B4A 8.8beta.
I expect this waring in older versions too.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
No. You just do not need it...

It is written at a time i was in investigation on how it works, whether i need to wrap more or not... I found out that we do NOT need it at all. the logic is in the java-code.
Thanks for your reply.

For information (to those use this library), all the lines with "Log()" need to be disable, because if don't, will get this error below in B4A 8.80 Beta:
B4X:
** Activity (main) Create, isFirst = true **
content://de.donmanfred.sticker42.stickercontentprovider/metadata
[com.sticker4w.StickerPack@d735261]
loader.fetchStickerPacks
[com.sticker4w.StickerPack@539d186]
1
content://de.donmanfred.sticker42.stickercontentprovider/stickers_asset/1/Cuppy
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
ion_Event(ResultArrived, -1, Intent { (has extras) })
main_ion_event (java line: 443)
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
    at anywheresoftware.b4a.BA.addLogPrefix(BA.java:587)
    at anywheresoftware.b4a.keywords.Common.LogImpl(Common.java:190)
    at de.donmanfred.sticker42.main._ion_event(main.java:443)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4j.object.JavaObject$1.invoke(JavaObject.java:237)
    at java.lang.reflect.Proxy.invoke(Proxy.java:813)
    at $Proxy0.ResultArrived(Unknown Source)
    at anywheresoftware.b4a.BA$4.run(BA.java:568)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:442)
    at de.donmanfred.sticker42.main$ResumeMessage.run(main.java:306)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6123)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
 
Upvote 0

asales

Expert
Licensed User
Longtime User
the result is not really a string. But as we are using it in the LOG() it is converted to a String.
that´s the reason for the warning.

Edit to add: i don´t think it is related to B4A 8.8beta.
I expect this waring in older versions too.
Thanks again.
Like I write in the post above, I get an error in B4A 8.80 Beta if I don't comment the lines with Log().
But disable the lines works fine and there is no similar issue in B4A 8.50.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
If you want to suppress the warnings, just put "'ignore" at the end of the line that is generating the warning - eg:

B4X:
Log(contparser.parseStickerPacks(instr)) 'ignore

- Colin.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I need to do something with this code?
i rechecked the example.

You just can remove all Code related to ContentFileParser and StickerPackLoader. They are not needed.

Change the ion_Event code to

B4X:
Sub ion_Event (MethodName As String, Args() As Object) As Object
    Log($"ion_Event(${MethodName}, ${Args(0)}, ${Args(1)})"$)
    If Args(1) <> Null Then
        Dim in As Intent = Args(1)
        'Log("Extra: "&in.ExtrasToString)
        'Log(in.GetData)
        'Extra: Bundle[{add_successful=true}]
        ' NEW
        ' NEW
        ' NEW
        If in.HasExtra("add_successful") Then                      
            Dim added_successfully As Boolean = in.GetExtra("add_successful")
            Log($"Sticker added successffuly: ${added_successfully}"$)
        End If
        ' NEW
        ' NEW
        ' NEW
        If in.HasExtra("validation_error") Then
            Dim info As String = in.GetExtra("validation_error")
            Log($"Validation-Error: ${info}"$)
        End If
    End If
    'Args(0) = resultCode
    'Args(1) = intent
    Return Null
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…