Android Question Switch focus between two apps (Service)

Discussion in 'Android Questions' started by ElliotHC, Aug 11, 2019.

  1. ElliotHC

    ElliotHC Active Member Licensed User

    I have two apps running.

    1. Camera
    2. Another App

    When the volume up is pressed, I want to bring app 2 to focus.. It will run the code, then bring the camera to focus again until the next volume up event.

    Does anyone know if this is possible?
     
  2. DonManfred

    DonManfred Expert Licensed User

    How are you able to run two apps at the same time? Only ONE avtivity can be in Front (Active). There can not be any other app with a visible Activity too at the same time.
     
  3. ElliotHC

    ElliotHC Active Member Licensed User

    This is my thinking...

    My app is running a service which looks for a volume down.

    The camera is currently running waiting for the volume down to trigger and take a video clip..

    On seeing the volume down, my service waits for a period of time (enough to allow the slow motion video clip to be taken and file to be saved)

    It then makes itself active which will run the code to do what it needs to with the files, then opens the camera again when it's done ready for the next video clip.

    I'm trying this but the camera won't open.

    Code:
    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.
        Dim Pm As PackageManager 'Phone library
        Dim Inte As Intent
    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)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        'Activity.LoadLayout("Layout1")
        For Each st As String In Pm.GetInstalledPackages
            
    Log(st)
            
    If st.Contains("camera") =True Then
                Inte=Pm.GetApplicationIntent(st)
                
    If Inte.IsInitialized Then StartActivity(Inte)
                
    Exit
            
    End If
        
    Next
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub
    It's clearly on the list.
    upload_2019-8-11_10-2-32.png
    calc opens just fine.
     
  4. DonManfred

    DonManfred Expert Licensed User

  5. ElliotHC

    ElliotHC Active Member Licensed User

  6. DonManfred

    DonManfred Expert Licensed User

    Didn´t you told in #1 of this thread that you have two apps running (i expect BOTH are YOUR Apps).
    Didn´t you say in #3 that the camera app is started?
     
  7. ElliotHC

    ElliotHC Active Member Licensed User

    No, I just have two apps.. The default camera app and my app..

    I'm pretty sure that I can everything working now but I need to know how to inialize and open the default camera app
     
  8. DonManfred

    DonManfred Expert Licensed User

  9. ElliotHC

    ElliotHC Active Member Licensed User

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