iOS Question B4I first time run app

Zak Petr

Member
Licensed User
Hello,

I need to know if B4i application is started at the first time after instalation.

I know that there is variable FirstTime at B4A like this example.
Sub Activity_Create(FirstTime As Boolean) .

Many thanks for your information.
 

JohnC

Expert
Licensed User
Longtime User
Keep in mind that the "FirstTime" value in B4A refers only to the first time that particular activity was shown for a new app "session" not a new app "installation". Meaning, if the user runs the app then exits the app after installing the app. The next time the user runs the app "FirstTime" will be set to True again.

What I do (in B4A) to detect if an app has been run for the very first time after an installation is use a preference setting:
B4X:
Sub Process_Globals
    Dim PrefManager As PreferenceManager
End Sub

If PrefManager.GetString("FirstRunAfterInstall") = "" then 'it is first run
     PrefManager.SetString("FirstRunAfterInstall", "No")  'so set value so won't be first run anymore
     ... [your first-run code here] ...
end if


After doing a search, there appears to be a Preference manager class for iOS that you could use:
 
Last edited:
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
Sub Activity_Create can be called many times, because you need to initialize Globals of the Activity (not Process_Globals) every time again. In B4i Application_Start is only called once, when the app starts. That's why you don't need the "FirstTime" parameter.
 
Upvote 0

watesoft

Active Member
Licensed User
Longtime User
Hello,

I need to know if B4i application is started at the first time after instalation.

I know that there is variable FirstTime at B4A like this example.
Sub Activity_Create(FirstTime As Boolean) .

Many thanks for your information.

you can use KeyValueStore:
Private kvs As KeyValueStore
Private Sub Application_Start (Nav As NavigationController)
    If File.Exists(File.DirDocuments, "Ini.dat") = False Then
        kvs.Initialize(File.DirDocuments, "Ini.dat")
        kvs.Put("value1",0)
    End If
    kvs.Initialize(File.DirDocuments, "Ini.dat")
    If kvs.Get("value1")<1 Then  '"1" is a mark that shows the times of app updating.
        'your action
        kvs.Put("value1",1)
    else
        'other action
    end if
End sub
 
Upvote 0

Similar Threads

Top