Activity.finish does nothing on Main?

Cableguy

Expert
Licensed User
Longtime User
Hi Erel,

I use activity.finish on other activities other than main, but on main it does nothing, and it seems that also, the UserClosed boolean seems to be ignored(see example zip).
Another things, when the main activity is loaded, and upon firststart=true I call another activity, one can see the controls of the main activity for a fraction of seconds...
another issue, is there any way to programatucally change the transition animation?
How can I use a for next loop to initialize or dim controls, like with the Control Keyword im B4P?

Thanks
 

Attachments

  • Finish.zip
    5.2 KB · Views: 268

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't see anything wrong when running your program.
This code doesn't really do anything:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed=True Then Activity.Finish
End Sub
Because when the user closes the activity (by pressing on the back button) then the activity gets finished. So calling it again doesn't do anything.

Another things, when the main activity is loaded, and upon firststart=true I call another activity, one can see the controls of the main activity for a fraction of seconds...
What is the purpose of the second activity? Is this a splash screen?
In most cases it is not recommended to start an activity only when the process starts for the first time. The process can alive for a long time and then when the user will start your application the second activity will not start.

The second activity will only start after your current activity is properly paused. Which means that first the current code runs, then Activity_Pause is run and only then the other activity starts. If you are creating the layout in Activity_Create then it will be visible for a short while.

How can I use a for next loop to initialize or dim controls, like with the Control Keyword im B4P?
You can do all kinds of things.
Here is one example:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    For i = 0 To 15
        Dim b As Button
        b.Initialize("btn")
        b.Text = "btn" & i
        b.Tag = i
        Dim row, col As Int
        col = i Mod 4
        row = Floor(i / 4)
        Activity.AddView(b, 20dip + col * 70dip, 20dip + row * 70dip, 65dip, 65dip)
    Next
End Sub

Sub btn_Click
    Dim btn As Button
    btn = Sender
    Msgbox("You pressed on button: " & btn.Tag, "")
End Sub

11_21_1.png
 

Cableguy

Expert
Licensed User
Longtime User
Yes, the zip was just an empty shell, just to try to show what I meant, but with your explanaition, I now see that a SplashScreen is somewhat dificult to achieve...
From what I understand from your example, view naming is not important, as all the buttons on it were called "b", and only diferenced by its Tag prop...
Thats a nice tip, Thanks...

Waht about RIL services? any due date on that?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are all kinds of splash screens. Here is one that displays a red panel while the layout is created (you can add other items to this panel):
B4X:
    Dim Panel As Panel
    Panel.Initialize("")
    Panel.Color = Colors.Red
    Activity.AddView(Panel, 0, 0, 100%x, 100%y)
    DoEvents

   'load the layout here
    
    Activity.RemoveViewAt(0) 'remove the panel

What do you mean with RIL services?
 

Cableguy

Expert
Licensed User
Longtime User
Phone related Dll, such as interception os sms, etc...
 

Cableguy

Expert
Licensed User
Longtime User
Great News!!!!!
 
Top