Android Question Launching another APP with intent

freedom2000

Well-Known Member
Licensed User
Longtime User
Hi all,

First of all, I wish you a really happy new year with a lot of B4X projects :)

I am trying to add a better webcam to my JG eCatFeeder

I have found this excellent App : IP WebCam

The author says that we can launch the App with an intent and provides the code :

B4X:
public void onClick(View v) {
                Intent launcher = new Intent().setAction(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME);
                Intent ipwebcam =
                    new Intent()
                    .setClassName("com.pas.webcam", "com.pas.webcam.Rolling")
                    .putExtra("cheats", new String[] {
                            "set(Photo,1024,768)",         // set photo resolution to 1024x768
                            "set(DisableVideo,true)",      // Disable video streaming (only photo and immediate photo)
                            "reset(Port)",                 // Use default port 8080
                            "set(HtmlPath,/sdcard/html/)", // Override server pages with ones in this directory
                            })
                    .putExtra("hidebtn1", true)                // Hide help button
                    .putExtra("caption2", "Run in background") // Change caption on "Actions..."
                    .putExtra("intent2", launcher)             // And give button another purpose
                    .putExtra("returnto", new Intent().setClassName(ApiTest.this,ApiTest.class.getName())); // Set activity to return to
                startActivity(ipwebcam);
            }

I have tried to port this into B4A, but all my attempts failed...
(the extra are not mandatory). Here is the text of explaination : You can start the IP Webcam with the Android intent containing class com.pas.webcam.Rolling. You can optionally pass ArrayList named "cheats" for reconfiguring IP Webcam before starting the server. You can also change the text on buttons, hide them and modify their actions by passing proper extra fields.

and my code which totally fails...

B4X:
Sub Button1_Click
   
    Dim myIntent As Intent
    myIntent.Initialize("com.pas.webcam.Rolling","")
    myIntent.Action=myIntent.ACTION_MAIN
    myIntent.AddCategory("android.intent.CATEGORY_HOME")
    StartActivity(myIntent)
End Sub

Any help please !
Thank you in advance.
 
Top