Trying to launch a subactivity of another app and pass extra's (Bundles()) to it

jdiperla

Member
Licensed User
Longtime User
SOLVED: Trying to launch a subactivity of another app and pass extra's (Bundles())

SOLVED: READ THE LAST POST.

Hello again.

In my app, I am trying to launch a subactivity in another application, but without success.

The Package name is:
package="com.gooku.android.launcher"

the sub-activity name is:
com.gooku.android.rouge

It has no categories. Its also not a MAIN action.

The package and its activities is not located in my apps resources. Its a standalone app seperate from my app.

I am trying to pass three extras to the subactivity (In Java it would be done with Bundle() ) filename, filedir, lastpos.

I do not think I am far off, but I can not seem to get it to load that app, launch the sub-activity and pass those extras to it.

Here is my code:

B4X:
Try
    Dim Intent1 As Intent
   
    Intent1.Initialize("","")
   Intent1.SetComponent("com.gooku.android.launcher/.rouge")
   Intent1.PutExtra("filename", "glaunch.exe")
   Intent1.PutExtra("directory", File.DirRootExternal & "gooku")
   Intent1.PutExtra("lastpos", "false")
   
   
   StartActivity (Intent1)
      Catch
      ToastMessageShow ("Failed to launch app!  Is it installed?", True)
  End Try

I keep getting the failed to launch app message. Any idea's?
 
Last edited:

giga

Well-Known Member
Licensed User
Longtime User
Hello again.

In my app, I am trying to launch a subactivity in another application, but without success.

The Package name is:
package="com.gooku.android.launcher"

the sub-activity name is:
com.gooku.android.rouge

It has no categories. Its also not a MAIN action.

The package and its activities is not located in my apps resources. Its a standalone app seperate from my app.

I am trying to pass three extras to the subactivity (In Java it would be done with Bundle() ) filename, filedir, lastpos.

I do not think I am far off, but I can not seem to get it to load that app, launch the sub-activity and pass those extras to it.

Here is my code:

B4X:
Try
    Dim Intent1 As Intent
   
    Intent1.Initialize("","")
   Intent1.SetComponent("com.gooku.android.launcher/.rouge")
   Intent1.PutExtra("filename", "glaunch.exe")
   Intent1.PutExtra("directory", File.DirRootExternal & "gooku")
   Intent1.PutExtra("lastpos", "false")
   
   
   StartActivity (Intent1)
      Catch
      ToastMessageShow ("Failed to launch app!  Is it installed?", True)
  End Try

I keep getting the failed to launch app message. Any idea's?

Not sure If you can do that. I ran into the same issue (Failed to launch) sending an EXTRA to the busybox terminal app. Sorry.
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
Hmmm...

But what exactly is preventing it from working? I mean, technically, it should work just fine. It has the SetComponent, it has the main package and it has the extra's. If it were done completely in Java, this would have been done already without a problem.

My only concern is that maybe this might be the issue:

com.gooku.android.launcher is the main app and the sub-activity is
com.gooku.android.rouge and I am trying to intent it with com.gooku.android.launcher/.rouge

But, even so, I would think that wouldn't prevent it from working. Grrr... I really need this to work some how.
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
Fixed it. First off, the sub-activity in the androidmanifest.xml file needs to have this line in it:

B4X:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>

This gives it permission to load that activity. Then, I just needed to adjust my code to read like this:

B4X:
Try
    Dim Intent1 As Intent
    
    Intent1.Initialize("","")
    Intent1.SetComponent("com.gooku.android.launcher/" & "com.gooku.android.rouge")
    Intent1.PutExtra("filename", "glaunch.exe")
    Intent1.PutExtra("directory", File.DirRootExternal & "gooku")
    Intent1.PutExtra("lastpos", "false")
   
   
    StartActivity (Intent1)
      Catch
      ToastMessageShow ("Failed to launch app!  Is it installed?", True)
  End Try

Notice the difference in Intent1.SetComponent. I have no idea why it has to be done that way, but whatever I tried would not work, so hopefully, this is something that all of you find useful in using. Thanks for looking!
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
One last thing about this.. Just for everyone's information. But the app being called also needs to be sent to publicly declared strings or variables and not private ones. If its in a sub, it cant be protected. It has to be public void. Hope this helps anyone in the future.
 
Upvote 0
Top