Android Question What is the eqvt. of a 'Starter' file in a B4X Page application - reg.

beelze69

Active Member
Licensed User
Longtime User
Hi,

I have a small application which fetches data from an SQLLITE database.

It is an Activity Based Application.

Key declarations in the 'Starter' file :

1) Sub Process_Globals:

1.1) Public variable to hold the DbName in Process_Globals
1.2) A User-Defined-Fields Data Type

2) Other routines in the Starter File:

Sub Service_Create


SafeDirectory = RTP.GetSafeDirDefaultExternal("")

If File.Exists(SafeDirectory, DBName) = False Then
Wait For (File.CopyAsync(File.DirAssets, DBName, SafeDirectory, DBName)) Complete (Success As Boolean) 'File.DirInternal
ToastMessageShow($"DB Copied = ${Success}"$, False)
' Log("Success: " & Success)
End If

ConnectToTheDatabase
Wait For SQLite_Ready (Success As Boolean)
End Sub

Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub

Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub

Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub

Sub Service_Destroy
End Sub

Public Sub ConnectToTheDatabase
SQL.Initialize(SafeDirectory, DBName, False)
End Sub



3) My 'Activity' based application works fine presently.

My doubt:

I wish to convert the Activity based application into a B4XPage application.

So where should I place all the above declaration routines when we create a B4XPage , the
Starter file is not created by default .

So what are the eqvt. subroutines in a B4XPage variant ?

Sorry if I sound too basic.

Thanks.
 

beelze69

Active Member
Licensed User
Longtime User
You can move all the code you have in the Starter module into the B4XMainPage module.
Hi Klaus,

Thanks for the immediate reply.

You mean

Sub Service_Create

Sub Service_Start

Sub Service_TaskRemoved

Sub Application_Error

Sub Service_Destroy

As for the Process_Globals , I understand that we have to declare these variables
as Public in

Sub Class_Globals of the B4xMainPage. to make it accessible to all 'future Pages' that will be created.

I have a small doubt here..

1) The entry point of an Activity Based app is the Sub Service_Create (which is in Starter file in an Activity based app) .

If I place this subroutine in the B4XMainPage, will this subroutine be still the entry point ?

2) Why can't we directly place the Starter file in a B4XPage based app.


Thanks..
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
No.
Only the code concerning SQLite or any other file management code.
You can leave the Starter Service module in your project if you want.

2) Why can't we directly place the Starter file in a B4XPage based app.
You can, but it will not be cross-platform.

If you create a new B4XPages project with the B4XPages template, there is no Starter module. Wrong., see post #10.

In the B4X Booklets, in the source code of the B4X SQLite database booklet, there does exist a B4XPages example of the SQLiteLight2 project called B4XPages_SQLiteLight2.
 
Last edited:
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
No.
Only the code concerning SQLite or any other file management code.
You can leave the Starter Service module in your project if you want.


You can, but it will not be cross-platform.

If you create a new B4XPages project with the B4XPages template, there is no Starter module.

In the B4X Booklets, in the source code of the B4X SQLite database booklet, there does exist a B4XPages example of the SQLiteLight2 project called B4XPages_SQLiteLight2.
Thanks Klaus.. I worked ... presently I have no intentions to make it cross-platform..So it is okay... Thank you very much
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
My apologies !!!
If you create a new B4XPages project with the B4XPages template, there is no Starter module.
This is WRONG !!!
When you create a new B4XPages project, the Starter module is there but hidden by default, according to Erels' answer here.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
My apologies !!!

This is WRONG !!!
When you create a new B4XPages project, the Starter module is there but hidden by default, according to Erels' answer here.
That's why I said 'check modules'.

ba1.png

It shows in modules tab.
 
Upvote 0
Top