Android Question start an app with startactivity

tmtube73

Active Member
Licensed User
good morning everyone, i should start an app with startactivity, my app is called "means" i tried to call the command

StartActivity ("means")

but it doesn't work, is there a way to know what to write in parentheses to start a certain app installed in the phone?
 

tmtube73

Active Member
Licensed User
i tried to run this sub but it stops the app and does not open the other app

B4X:
Sub ApriMezzi

    Dim In As Intent
    In.Initialize("","")

    In.SetComponent("appinventor.ai_myname.myapp/.Screen1")    '<-- for instance "b4a.example/.main"

    Dim FLAG_DISMISS_KEYGUARD As Int = 0x00400000
    Dim FLAG_TURN_SCREEN_ON As Int   = 0x00200000

    In.Flags = Bit.Or(FLAG_TURN_SCREEN_ON, FLAG_DISMISS_KEYGUARD )
 
    StartActivity(In)

End Sub
 
Upvote 0

tmtube73

Active Member
Licensed User
debugging the line

B4X:
StartActivity(In)

I got this error message

Error occurred on line: 112 (Starter)
android.content.ActivityNotFoundException: Unable to find explicit activity class {appinventor.ai_amorosik4.MEZZI/appinventor.ai_amorosik4.MEZZI.Screen1}; have you declared this activity in your AndroidManifest.xml?
 
Upvote 0

tmtube73

Active Member
Licensed User
yes i want to open an app made with external app inventor named "mezzi" i know the package and i know the name of the first screen of the app which is Screen1
 
Upvote 0

tmtube73

Active Member
Licensed User
I seem to have guessed that I have to declare my activity in the android manifest file?

I saw your message before but the app I have to follow is an app developed in the appinventor
 
Upvote 0

tmtube73

Active Member
Licensed User
it gives me a compilation error, but I have already selected the phone library

B4X:
B4A Version: 9.80
Java Version: 11
Analysis of the Code. (0.00s)
Building folders structure. (0.01s)
Compiling the code. error
Error in compiling the program.
Error description: The current declaration does not correspond to the previous one.
Previous: {Type = Phone, Rank = 0, RemoteObject = True}
Current: {Type = PackageManager, Rank = 0, RemoteObject = True}
Line error: 87
Dim p As PackageManager
 
Upvote 0

tmtube73

Active Member
Licensed User
I also tried this way, but by debugging the message that intent1 is not initialized, can someone help me understand?

B4X:
    Dim Intent1 As Intent
    Dim pm As PackageManager
    Intent1 = pm.GetApplicationIntent("appinventor.ai_miapp.appname")
    'Dim Packages As List
    'Packages = pm.GetInstalledPackages
    'For i = 0 To Packages.Size -1
    ' Log(Packages.Get(i))
    'Next
    Try
        StartActivity(Intent1)
    Catch
        ToastMessageShow("Cannot start file. " & CRLF & "appname", False)
    End Try
 
Upvote 0
Top