Android Question Launch another activity

nibbo

Active Member
Licensed User
Longtime User
Hi all

I want to wrap a few related apps up into one and allow the user to launch them all from one screen. How do I launch one app from another?

I found an example on here but when I run my launcher app I get the error:
'android.content.ActivityNotFoundException: Unable to find explicit activity class {package.name/package.name.Activity}; have you declared this activity in your AndroidManifest.xml?'

It looks like I need to add something to the manifest file for this to work?

The code I am using is:
B4X:
Dim myIntent As Intent
myIntent.Initialize(myIntent.ACTION_MAIN,"")
myIntent.SetComponent("package.name/.activity")
StartActivity(myIntent)

Thanks
 

nibbo

Active Member
Licensed User
Longtime User
i believe package manager can help you listing all installed apps
https://www.b4x.com/android/help/phone.html#packagemanager

this looks wrong "package.name/.activity"
every app have a different package name and you can choose the name of the start activity.

I have just used that as an example, the actual package name is the same as the one specified in the build configurations.
It is listed when I look at the list returned from package managers' GetInstalledPackages.
Thanks
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
i used this to log all apps and start the calculator, in your case a example parameter "com.android.calculator2/.Calculator"
B4X:
Sub Taschenrechner_Click
    
    'Erels' answer to the question: You can start any application by sending the correct Intent.
    'The easiest way to see the required Intent is to look at the unfiltered logs while manually starting the application.
 
    'The code below shows how To run an Application from another one.
    'The PackageManager Is an object in the Phone library. The exact package name Is needed !
 
    Private pm As PackageManager
    Private in As Intent
 
    in.Initialize("", "")
    'in.SetComponent("com.android.calculator2/.Calculator") 'so geht das angeblich auch
    'com.google.android.youtube
    'com.android.providers.calendar
    'com.motorola.camera
    'com.android.contacts
    'com.google.zxing.client.android
    'com.deufol.bc.client.android
    'com.android.chrome
    'com.google.android.calendar
    'com.android.calculator2
    'com.android.email
    'com.android.phone
    
    For Each name In pm.GetInstalledPackages
        Log(name)
        If name = "com.android.calculator2" Then
            in = pm.GetApplicationIntent(name)
            If in.IsInitialized Then
                StartActivity(in)
            End If
        End If
    Next
    
End Sub
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
If your other app package name is: other.app.package:
B4X:
myIntent.Initialize(myIntent.ACTION_MAIN,"")
myIntent.SetComponent("other.app.package/.main")

Thanks Erel, I had actually put one of the activities in the bit after /.
It looks like we can only put /.main which seems to work OK.
Thanks for your help.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
i guess it is this part in manifest
<intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter>
 
Upvote 0
Top