launch activities from different package
I am assuming that by "packages" you mean applications.
We have:
- ApplicationA with FirstActivity
- ApplicationB with SecondActivity
If, in the ApplicationB's AndroidManifest.xml file, in the declaration of SecondActivity you add an intent filter such as:
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="applicationB.intent.action.Launch" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
You can create an Intent to launch this SecondActivity from the FirstActivity with:
Intent intent = new Intent("applicationB.intent.action.Launch");
startActivity(intent);
What this all means is:
- The SecondActivity has a filter for the intent action of "applicationB.intent.action.Launch"
- When you create an intent with that action and call 'startActivity' the system will find the activity (if any) that responds to it
The documentation for this is at: https://developer.android.com/reference/android/content/Intent.html
Launching Activities via package names
I figured out a method that worked for me, though Brandon's could possibly work on another solution. Here is my solution:
Intent intent = new Intent("com.REDACTED.auto.diagnostics.dealer.MAIN");
intent.setClassName("com.REDACTED.auto.diagnostics",
"com.REDACTED.auto.diagnostics.dealer.MainActivity");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Context c = InstrumentationRegistry.getContext();
c.startActivity(intent);
This possibly does the same thing that Brandon's solution does, however less abstracted.
How do I launch a specific (explicit) activity of another app
Try this:
Intent intent = new Intent();
intent.setClassName("com.pas.webcam.pro", "com.pas.webcam.Rolling");
startActivity(intent);
Since you refer to the app as "IP webcam pro", I'm assuming the package name is "com.pas.webcam.pro" (found by Internet research).
Unable to start activity from the different package [Android]
Its possible :) and your launch is correct, so it must be setup that is something wrong with. To be exact you should start activity2 from activity1 why you ask well the manifest is the answer I say. You see the package refered to in the manifest is where your main activity should reside.
Related Topics
How to Set a Particular Font for a Button Text in Android
How to Run Code on a Background Thread on Android
Android Studio Gradle Icon Error, Manifest Merger
Android Edittext - Finished Typing Event
Sending a Notification from a Service in Android
How to Use Onsaveinstancestate() and Onrestoreinstancestate()
Android Webview "Tel:" Links Show Web Page Not Found
Android: Resize Only Parts of View with Soft Keyboard on Screen
How to Implement Cookie Handling on Android Using Okhttp
Android - Get Text Out of Webview
How to Generate an Md5 Checksum for a File in Android
Android - Setonclicklistener VS Onclicklistener VS View.Onclicklistener
How to Make a Horizontal Listview in Android
How to List Files in an Android Directory
How to Always Run a Service in the Background
Error:Failed to Open Zip File. Gradle's Dependency Cache May Be Corrupt
Use "Enter" Key on Softkeyboard Instead of Clicking Button
How to Re-Sign an .Apk with a Different Certificate Than What It Came With