Start activity from intent

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hi,

I'm trying to use StartActivity to start an activity from my own project, however using an intent!

Activity: TopAct
Packagename: com.rootsoft.viewcontainer


So something like this, but it doesn't show my activity.
B4X:
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_MAIN, "")
Intent1.SetComponent("com.rootsoft.viewcontainer.HomeActivity")
StartActivity(Intent1)

Note that I need to use an intent and not

B4X:
StartActivity(TopAct)

Regards,
Tomas
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
This results in the following error:

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.rootsoft.viewcontainer/com.rootsoft.viewcontainer.HomeActivity}; have you declared this activity in your AndroidManifest.xml?

also trying with:
B4X:
Intent1.SetComponent("com.rootsoft.viewcontainer/.TopAct") 'Package and class name

gives me the error, but this:

B4X:
Intent1.SetComponent("com.rootsoft.viewcontainer.TopAct") 'Package and class name

Opens an selection thing which i can choose from various apps:
Accu
Adobe Air
Adobe Flash Player
Agenda
...

and whenever i select one, it crashes.

Tomas
 
Last edited:
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
I did not declare the activity in the editor.
You should know that i need to start a Basic4Android activity from an intent and not from a library. (so we don't need to declare the activity in the manifest.(?))

However, after some debugging with Martin, it seemed that the packagename + class should have been lowercased:

B4X:
Dim Intent1 As Intent
   'Intent1.Initialize("", "")
   Intent1.Initialize(Intent1.ACTION_MAIN, "")
   Intent1.SetComponent("com.rootsoft.viewcontainer/.topact")

Probably because due compiling the classnames get lowercased, which now seems to work.

Regards,
Tomas
 
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
Well, that was my problem.
I had to use an intent to start my activity.

I'm using the following code to start an activity and embed it in a view.
This way, it will be easier to create native StandOut apps by creating the activities instead of manually.

B4X:
/**
    * Loads an activity in a window.
    */
   public View LoadActivityInWindow(String uniqueID, IntentWrapper i) {
      
      android.view.Window w = mgr.startActivity(uniqueID, i.getObject());
      View wd = w != null ? w.getDecorView() : null;
      return wd;
      
   }

B4X:
Sub mnuIntent_Click

   Dim Intent1 As Intent
   Intent1.Initialize(Intent1.ACTION_MAIN, "")
   Intent1.SetComponent("com.rootsoft.viewcontainer/.topact")
   
   Dim v As View
   v = window.LoadActivityInWindow(1, Intent1)
   Panel1.AddView(v, 0dip, 0dip, Panel1.Width, Panel1.Height)

End Sub

As you can see, i needed an intent to start the activity.

Tomas
 
Upvote 0
Top