B4A Class ActivityManager(which you can finish all activity in anywhere)

Discussion in 'Additional libraries, classes and official updates' started by icefairy333, Jul 8, 2016.

  1. icefairy333

    icefairy333 Active Member Licensed User

    Code:
    'Code module
    'this module use to exit all activity from anywhere,using this you must add
    'comm.addthis(comm.getthis(Me)) in your each activity_oncreate sub
    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.
        Private lstAct As List
    End Sub

    public Sub getthis(obj As Object) As Object
        
    Dim ref As Reflector
        ref.Target=obj
        
    Return ref.GetActivity
    End Sub
    Public Sub addthis(obj As Object)
        
    If lstAct.IsInitialized=False Then lstAct.Initialize
        lstAct.Add(obj)
    End Sub
    public Sub exitall
        
    Dim act As Reflector
        
    For i=0 To lstAct.Size-1
            act.Target=lstAct.Get(
    0)
            
    Try
            act.RunMethod(
    "finish")
            
    Catch
                
    Log(LastException.Message)
            
    End Try
            lstAct.RemoveAt(
    0)
        
    Next
        
    StopService(Starter)
        
    ExitApplication
    End Sub
     

    Attached Files:

  2. MarcoRome

    MarcoRome Expert Licensed User

    Good work icefairy +10 ;)
     
  3. Dey

    Dey Active Member Licensed User

    Thank you
    you solved a big problem with a lot of activity loaded
    :)
     
    icefairy333 likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice