Example First Run EULA code?

niteuser

New Member
Licensed User
Longtime User
Hello,

To comply with some services app submissions guidelines they want you to display a internet usage fees may apply dialog to the end users upon first running. Does anyone have some example code to share to make this happen?

Thanks
 

NJDude

Expert
Licensed User
Longtime User
A very simple way to do it:
B4X:
Sub Activity_Create(FirstTime As Boolean)

    If File.Exists(File.DirDefaultExternal, "EULA.txt") = False Then
            
       File.OpenOutput(File.DirDefaultExternal, "EULA.txt", False)
                     
       ToastMessageShow("Read the EULA", True)
                     
    End If

End Sub

In this sample, the EULA message will display ONLY THE VERY FIRST TIME the app is installed.
 
Upvote 0

niteuser

New Member
Licensed User
Longtime User
Thanks this is just what I needed, to submit app to blackberry app world. I Mod it a little for allow internet application run.

B4X:
Sub Activity_Create(FirstTime As Boolean)

If File.Exists(File.DirDefaultExternal, "YOURAPPNAMEEULA.txt") = False Then
                            
       If Msgbox2("This software uses the internet and usage fees may apply, do you want to allow the connection?", "Internet Usage", "Yes - I Accept", "", "No", Null) = DialogResponse.POSITIVE Then
         File.OpenOutput(File.DirDefaultExternal, "YOURAPPNAMEEULA.txt", False)
        Else
           Activity.Finish
        End If
                            
    End If

'app start functions here

End Sub
:sign0098:
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
A very simple way to do it:
B4X:
Sub Activity_Create(FirstTime As Boolean)

    If File.Exists(File.DirDefaultExternal, "EULA.txt") = False Then
            
       File.OpenOutput(File.DirDefaultExternal, "EULA.txt", False)
                     
       ToastMessageShow("Read the EULA", True)
                     
    End If

End Sub

In this sample, the EULA message will display ONLY THE VERY FIRST TIME the app is installed.

Shouldn't the line be True?

B4X:
If File.Exists(File.DirDefaultExternal, "EULA.txt") = True Then

And the EULA will display again if the app is taken fully out of memory right? or Forced closed by the user.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
The "EULA.txt" file is used as a flag, if IT DOESN'T exists means is the very first time the app was ran, that's why it's being created, so, the next time the app is ran it will not show up again.

The only time the EULA will show again is if the user uninstalls the app and installs it again.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Ahhh...got it...I thought the text was coming out of the EULA.txt file.

If the app is uninstalled, won't the file still be there?
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Hmmm...my app creates a data.dat file to store various values and I just did an uninstall and the data.dat file is still there.
 
Upvote 0
Top