Android Question B4A V12.00 SDK31 Android Version 12 - Pb with StdActionBar V1.52

imbault

Well-Known Member
Licensed User
Longtime User
Hello, I'm having issue with StdActionBar only on Android V 12 (android:targetSdkVersion="31")

On all my other device running Android V 11, it works like a charm...

Any help would be appreciated

Sub Activity_Create(FirstTime As Boolean):
Sub Activity_Create(FirstTime As Boolean)
    status.Initialize
    status.put("Réservé(s)","B") 'Booked
    status.put("Encours","P") 'Pending
    status.put("Terminé(s)","C") 'Completed
    status.put("Envoyé(s)","S") 'Sent

    bar.Initialize("bar")
 
    For i=0 To status.Size -1
        bar.AddTab(status.GetKeyAt(i)).Tag=status.GetValueAt(i)
    Next

the Issue seems to be here:

Sub Activity_Resume:
Sub Activity_Resume

    If Forcestatus <> "" Then
        bar.SelectedIndex=0
        Forcestatus =""
    Else
        For i=0 To status.Size -1
            If status.GetValueAt(i)=cMainstatus Then
                Log("status " & status.GetValueAt(i))
                Log("mainstatus " & cMainstatus)
                Log("i " & i)
                Log("bar item " & i)
                bar.SelectedIndex= i
            End If

        Next
     
    End If
    HandleViewRDV
 

End Sub

With this error :
B4X:
main_activity_resume (java line: 1369)
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setSelectedNavigationItem(int)' on a null object reference
    at anywheresoftware.b4a.objects.StdActionBar.setSelectedIndex(StdActionBar.java:256)
    at com.pitechnic.smile.main._activity_resume(main.java:1369)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at com.pitechnic.smile.main.afterFirstLayout(main.java:111)
    at com.pitechnic.smile.main.access$000(main.java:17)
    at com.pitechnic.smile.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:329)
    at android.app.ActivityThread.main(ActivityThread.java:8058)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)

Thank you
 

imbault

Well-Known Member
Licensed User
Longtime User
I've tested this on an Android 13 and it works. Does it fail on your device?
BTW, I don't recommend using StdActionBar for new projects. I prefer TabStripViewPager.
Dear Erel,

Thank you with this sample, it works, it seems I have pb with FusedLocationProvider or other stuff running at servive like bluetooth and localisation...

Thanks again

Patrick
 
Upvote 0
Top