Hi,
In my application I have 3 activity's:
Main
SairamdoSite1
SairamdoSite2
Main Activity code
SairamdoSite1 Activity code
SairamdoSite2 Activity Code
Legend:
I have put 3 buttons on the (SairamdoSite1) activity that have this info:
SetaEsquerdaButton1 -> Left Button
SetaDireitaButton1 -> Right Button
SetaPrincipalButton1 -> Main Page Button
the objective of the button's would be:
If I am on "SairamdoSite1" activity the button's would do this:
SetaEsquerdaButton1 -> Will finish the activity and go to my main activity
SetaDireitaButton1 -> Will go to my "SairamdoSite2" activity
SetaPrincipalButton1 -> Will finish the activity and go to my main activity
it works as I intended to work but,
If I am on "SairamdoSite2" activity the button's would do this:
SetaEsquerdaButton1 -> Will finish the activity and go to my "SairamdoSite1" activity
SetaDireitaButton1 -> Will go to my "SairamdoSite3" activity (That is commented, not active yet)
SetaPrincipalButton1 -> Will finish the activity and go to my main activity (In here is where it resides my big problem, if I finish this activity, it will go to the "SairamdoSite1" activity and not the "Main" activity that I want the effect to be.
If instead of:
Activity.Finish
I put
StartActivity(Main)
it will not finish my "SairamdoSite2" activity, after being in the "Main" I press the "Exit application Button" that I have there pointing out to a:
This would finish the Main activity but will open my earlier activity the "SairamdoSite2" Activity , and not exit the entire program as I want it
If I put "ExitApplication" instead of "Activity.Finish" it will go to my "SairamdoSite2" Activity and crash the program
Can anyone help me out to solve this problem?, I really would like to have this buttons in my application, the left button to bring me back to the previous activity, the right button to take me to the next activity, and "a main Button" to anywhere I am on my application pressing that button would finish whatever activity I am on and put me back in the Main activity.
Is this possible or I am asking for some impossible thing , thanks in advance, help would really be appreciated. :sign0085:
Joel :BangHead:
In my application I have 3 activity's:
Main
SairamdoSite1
SairamdoSite2
Main Activity code
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim MediaPlayer1 As MediaPlayer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("menu_principal")
End Sub
Sub SairamdositeButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
StartActivity(SairamdoSite1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
SairamdoSite1 Activity code
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim MediaPlayer1 As MediaPlayer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("sairamdosite1")
End Sub
Sub SetaEsquerdaButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
Activity.Finish
End Sub
Sub SetaDireitaButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
StartActivity(SairamdoSite2)
End Sub
Sub SetaPrincipalButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
Activity.Finish
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
SairamdoSite2 Activity Code
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim MediaPlayer1 As MediaPlayer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("sairamdosite2")
End Sub
Sub SetaEsquerdaButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
Activity.Finish
End Sub
Sub SetaDireitaButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
' StartActivity(SairamdoSite3)
End Sub
Sub SetaPrincipalButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
Activity.Finish
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Legend:
I have put 3 buttons on the (SairamdoSite1) activity that have this info:
SetaEsquerdaButton1 -> Left Button
SetaDireitaButton1 -> Right Button
SetaPrincipalButton1 -> Main Page Button
the objective of the button's would be:
If I am on "SairamdoSite1" activity the button's would do this:
SetaEsquerdaButton1 -> Will finish the activity and go to my main activity
SetaDireitaButton1 -> Will go to my "SairamdoSite2" activity
SetaPrincipalButton1 -> Will finish the activity and go to my main activity
it works as I intended to work but,
If I am on "SairamdoSite2" activity the button's would do this:
SetaEsquerdaButton1 -> Will finish the activity and go to my "SairamdoSite1" activity
SetaDireitaButton1 -> Will go to my "SairamdoSite3" activity (That is commented, not active yet)
SetaPrincipalButton1 -> Will finish the activity and go to my main activity (In here is where it resides my big problem, if I finish this activity, it will go to the "SairamdoSite1" activity and not the "Main" activity that I want the effect to be.
If instead of:
Activity.Finish
I put
StartActivity(Main)
it will not finish my "SairamdoSite2" activity, after being in the "Main" I press the "Exit application Button" that I have there pointing out to a:
B4X:
Sub SairButton1_Click
Mediaplayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "Click1.wav")
MediaPlayer1.Play
If Msgbox2("Deseja sair da aplicação?", "", "Sim", "", "Não", Null) = DialogResponse.POSITIVE Then
Activity.Finish
End If
End Sub
This would finish the Main activity but will open my earlier activity the "SairamdoSite2" Activity , and not exit the entire program as I want it
If I put "ExitApplication" instead of "Activity.Finish" it will go to my "SairamdoSite2" Activity and crash the program
Can anyone help me out to solve this problem?, I really would like to have this buttons in my application, the left button to bring me back to the previous activity, the right button to take me to the next activity, and "a main Button" to anywhere I am on my application pressing that button would finish whatever activity I am on and put me back in the Main activity.
Is this possible or I am asking for some impossible thing , thanks in advance, help would really be appreciated. :sign0085:
Joel :BangHead:
Last edited: