Android Question Class instance was not initialized (b4xpagesdelegator) on resume

cgili14

Member
Licensed User
Hello!
I need some help, I don't know what is causing this error to appear.
Didn't make any big changes to it and now the app dont even open

Console log:
Registro conectado a:  Xiaomi Redmi Note 7
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 62 (Main)
java.lang.RuntimeException: Class instance was not initialized (b4xpagesdelegator)
    at anywheresoftware.b4a.debug.Debug.shouldDelegate(Debug.java:242)
    at com.bitdesign.app.b4xpagesdelegator._activity_resume(b4xpagesdelegator.java:104)
    at com.bitdesign.app.main._activity_resume(main.java:490)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at com.bitdesign.app.main.afterFirstLayout(main.java:111)
    at com.bitdesign.app.main.access$000(main.java:17)
    at com.bitdesign.app.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7590)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Main Line 62:
Sub Activity_Resume
'    RequestRTP
    B4XPages.Delegate.Activity_Resume
End Sub

Thanks in advance!
 

cgili14

Member
Licensed User
Here is de Main activity:

B4X:
#Region  Project Attributes
    #ApplicationLabel: Appname
    #VersionCode: 1
    #VersionName: Appname1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
    #BridgeLogger: True
#End Region

#AdditionalRes: ../icon

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Process_Globals
    Public ActionBarHomeClicked As Boolean
    Public CorrectHeight As Int
    Public HeightChangedFired As Boolean
    Public Location As YourLocation
End Sub

Sub Globals
    Private ime As IME
    Private RTP As RuntimePermissions
End Sub

Sub Activity_CreatEMe(FirstTime As Boolean)
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
  
    ime.Initialize("ime")
    ime.AddHeightChangedEvent
    Location.Initialize
'    CorrectHeight = 100%y
'    Wait For ime_HeightChanged (NewHeight As Int, OldHeight As Int)
'    CorrectHeight = NewHeight
'    HeightChangedFired = True
End Sub

Sub ime_HeightChanged (NewHeight As Int, OldHeight As Int)
    B4XPages.GetManager.RaiseEvent(B4XPages.GetManager.GetTopPage, "IME_HeightChanged", Array(NewHeight, OldHeight))
End Sub

'Template version: B4A-1.01
#Region Delegates

Sub Activity_ActionBarHomeClick
    ActionBarHomeClicked = True
    B4XPages.Delegate.Activity_ActionBarHomeClick
    ActionBarHomeClicked = False
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
'    RequestRTP
    B4XPages.Delegate.Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
'    Location.GPS.Stop
    B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
    If Not(Result) Then
'        RequestRTP
''        B4XPages.MainPage.B4XImgArrow.mBase.SetRotationAnimated(500, 0)
'        Location.StartGps
    End If
End Sub

Sub Create_Menu (Menu As Object)
    B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
     processBA.raiseEvent(null, "create_menu", menu);
     return true;
  
}
#End If
#End Region

'Sub Process_Globals
' 
'End Sub
'
'Sub Globals
'    Private xui As XUI
'    Private ImageView1 As B4XView
'End Sub
'
'Sub Activity_Create(FirstTime As Boolean)
'    Activity.LoadLayout("Splash")
'    ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, "logo.png", ImageView1.Width, ImageView1.Height, True))
'    Sleep(3000)
'    StartActivity(Activity2)
'    Activity.Finish
'End Sub

Sub RequestRTP
    If Location.GPS.GPSEnabled = False Then
        ToastMessageShow("Please enable the GPS device.", True)
        StartActivity(Location.GPS.LocationSettingsIntent) 'Will open the relevant settings screen.
    Else
        RTP.CheckAndRequest(RTP.PERMISSION_ACCESS_FINE_LOCATION)
    End If
End Sub
 
Last edited:
Upvote 0

cgili14

Member
Licensed User
Hi Luca!
The RTP and the Location is there for testing proporses, I tryed to remove it and still giving me error.
IME must to be there on b4xpages.

I just found that
B4X:
Sub Activity_CreatEMe(FirstTime As Boolean)
says "CreateEMe"

Fixed now, thanks to everyone!!!
 
Upvote 0
Top