Android Question Activity Loading externals app's

Discussion in 'Android Questions' started by scsjc, Jul 22, 2015.

  1. scsjc

    scsjc Active Member Licensed User


    I want make service intercept when a user load a program, for that i'm use PackageName insisde of a service.

    Now i use StartServiceAt every 500ms and look if the program is load, and when screenoff (PhoneEvents library) change to high 6000ms and comingback screenon change to 500ms. But that use a hi battery. (before that im use timer, but the people kill all process and finaly the timer)

    is possible have a activity user when user touch screen or doing anything with phone ???
    Last edited: Jul 22, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why do you need to call StartServiceAt every 500ms? Use a foreground service instead (with StartServiceAt every few minutes).
  3. scsjc

    scsjc Active Member Licensed User

    I restart every 500ms, because when push button kill proceses finally. and i think making startserviceat every time fix that.
    I'm try to make a LookingAPP, (when user load "xxx app") the program lock phone...
    i show my code, and upload a sample.
    what you think??? Thanks.
    (Sorry for my english)

    #Region  Service Attributes
    #StartAtBoot: true
    #End Region

    Sub Process_Globals
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.
        Dim ActMan As JavaObject
    Dim R As Reflector
    Dim versionandroid As String
    Dim locked As Boolean = True
    Dim lowtime = 5000, hitime = 10000, curtime=5000 As Int
    Dim PackageName As String
    Dim PE As PhoneEvents
    Dim screenoff As Boolean=False
    Dim SF As StringFunctions
    End Sub

    Sub Service_Create

    'get version android
        ActMan = R.RunMethod2(
        versionandroid=R.GetStaticField (
    End Sub

    Sub Service_Start (StartingIntent As Intent)
    StartServiceAt(""DateTime.Now + curtime, True)

    If SF.Left(versionandroid,1)>=5 Then
    Dim TaskInfo As JavaObject = ActMan.RunMethod("getRunningAppProcesses",Array As Object())
    Dim CompInfo As JavaObject = TaskInfo.RunMethodJO("get",Array As Object(0))
            PackageName = CompInfo.GetField(
    Dim TaskInfo As JavaObject = ActMan.RunMethod("getRunningTasks",Array As Object(1))
    Dim CompInfo As JavaObject = TaskInfo.RunMethodJO("get",Array As Object(0)).GetField("topActivity")
            PackageName = CompInfo.RunMethod(
    End If

    Log(PackageName&" estado: "&locked & "intervalo: "&curtime)
    ToastMessageShow(PackageName&" estado: "&locked & "intervalo: "&curtime,False)  

    End Sub

    Sub Service_Destroy
    End Sub

    Sub PE_ScreenOn (Intent As Intent)
    StartServiceAt(""DateTime.Now + curtime, True)
    End Sub
    Sub PE_ScreenOff (Intent As Intent)
    End Sub
    Sub PE_UserPresent (Intent As Intent)
    End Sub

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

    Which button kills the process?
  5. scsjc

    scsjc Active Member Licensed User

    In samsung 5, when you push recent task (multitasking button), can you kill all processes, (right key option).

    For that reason I change the code. In the first time I make with a timer, but this key kill proces.
  6. Erel

    Erel Administrator Staff Member Licensed User

    If the user explicitly kills your app then StartServiceAt shouldn't work as well.
  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