How to start activity in another application?
If you guys are facing "Permission Denial: starting Intent..." error or if the app is getting crash without any reason during launching the app - Then use this single line code in Manifest
android:exported="true"
Please be careful with finish(); , if you missed out it the app getting frozen. if its mentioned the app would be a smooth launcher.
finish();
The other solution only works for two activities that are in the same application. In my case, application B doesn't know class com.example.MyExampleActivity.class
in the code, so compile will fail.
I searched on the web and found something like this below, and it works well.
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity"));
startActivity(intent);
You can also use the setClassName method:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.hotfoot.rapid.adani.wheeler.android", "com.hotfoot.rapid.adani.wheeler.android.view.activities.MainActivity");
startActivity(intent);
finish();
You can also pass the values from one app to another app :
Intent launchIntent = getApplicationContext().getPackageManager().getLaunchIntentForPackage("com.hotfoot.rapid.adani.wheeler.android.LoginActivity");
if (launchIntent != null) {
launchIntent.putExtra("AppID", "MY-CHILD-APP1");
launchIntent.putExtra("UserID", "MY-APP");
launchIntent.putExtra("Password", "MY-PASSWORD");
startActivity(launchIntent);
finish();
} else {
Toast.makeText(getApplicationContext(), " launch Intent not available", Toast.LENGTH_SHORT).show();
}
How to launch an Activity from another Application in Android 30
Android 11 added restrictions regarding the visibility of other apps. Apps that have targetSdk
set to >= 30 can't interact with and open other apps without specifying this in the manifest.
To specify that your app interacts with another specific app, you need to add a <queries>
element to your manifest file:
<manifest package="com.example.game">
<queries>
<package android:name="com.android.audioapp" />
</queries>
...
</manifest>
The link below contains other examples in case you need to specify a broader range of apps which you want to interact with.
Source: https://developer.android.com/training/basics/intents/package-visibility
Launch Activity from another Application Android
What you need to use are intent-filters
. Assume the activity to be launched is in the package launch.me
. Inside this applications manifest all the activities (main or otherwise) will be decalred by the <activity>
tag.
Assuming the activity you want to launch is inside the class file Launchme
. Then a portion of your manifest will be something like:
<activity android:name="launch.me.Launchme"
android:label="@string/app_name">
<intent-filter>
<action android:name="launch.me.action.LAUNCH_IT"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Now in the activity from where you want to launch the above activity use:(Note: This activity can be in any package anywhere. You have to make sure that both, the calling and the called packages are available on the device)
Intent i=new Intent();
i.setAction("launch.me.action.LAUNCH_IT");
startActivityForResult(i,0);
You can use other methods for starting the intent other than startActivityForResult
, thats upto you.
Starting a non-Main Activity from other app clearing its top
After a lot of research and tries, I've found that adding the next parameter to the activity in the manifest works like a charm. I hope this can help someone else:
android:launchMode="singleInstance"
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).
Related Topics
Set Up Device For Development (? No Permissions)
How to Customize a Progress Bar in Android
How to Force Use of Overflow Menu on Devices With Menu Button
How to Sign Android App With System Signature
Android Studio Doesn't See Device
Offline Speech Recognition in Android (Jellybean)
Android - Sms Broadcast Receiver
How to Detect When an Android Application Is Running in the Emulator
Android: How to Check If a View Inside of Scrollview Is Visible
How to Add Manifest Permission to an Application
Clicking Urls Opens Default Browser
How to Lay Out Views in Relativelayout Programmatically
Android Push Notifications: Icon Not Displaying in Notification, White Square Shown Instead