how to open other app activity from myapp?
Your package and class names do not match. Based on the manifest of the app you want to start, you need to change this:
intent.setClassName("com.rayvatapps.flatplan", "com.rayvatapps.flatplan.LoginActivity");
into this:
intent.setClassName("com.rayvatapps.flatmaps", "com.rayvatapps.flatmaps.LoginActivity");
You also don't need the <intent-filter>
on the Activity
in the app you are trying to start, as you are using an explicit Intent
to start it. If you remove the <intent-filter>
make sure that you keep the android:exported="true"
for the Activity
, otherwise you won't be able to launch it from another application.
Open another application from your own (intent)
Firstly, the concept of "application" in Android is slightly an extended one.
An application - technically a process - can have multiple activities, services, content providers and/or broadcast listeners. If at least one of them is running, the application is up and running (the process).
So, what you have to identify is how do you want to "start the application".
Ok... here's what you can try out:
- Create an intent with
action=MAIN
andcategory=LAUNCHER
- Get the
PackageManager
from the current context usingcontext.getPackageManager
packageManager.queryIntentActivity(<intent>, 0)
where intent hascategory=LAUNCHER
,action=MAIN
orpackageManager.resolveActivity(<intent>, 0)
to get the first activity with main/launcher- Get the
ActivityInfo
you're interested in - From the
ActivityInfo
, get thepackageName
andname
- Finally, create another intent with with
category=LAUNCHER
,action=MAIN
,componentName = new ComponentName(packageName, name)
andsetFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- Finally,
context.startActivity(newIntent)
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
android: how do i open another app from my app?
How to see if Intent is available:
Try calling Intent and deal with
ActivityNotFoundException
if it isn't availableIntent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(OpenPdf.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}or
Query the Package Manager to see if it is ahead of time:
PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/pdf");
List list = packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
intent.setDataAndType(path, "application/pdf");
startActivity(intent);
}
How to pass parameters to an application or know its capabilities:
- List of Available Intents for Google Applications
- List of Intents by 3rd parties @ OpenIntents
Android- launch another app from activity
I found the solution. In the manifest file of the application
I found My package name: com.package.address and the name of the Mainctivity which I want to launch:
The following code starts this application:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.package.address","com.package.address.MainActivity"));
startActivity(intent);
Related Topics
Edittext Seterror() with Icon But Without Popup Message
Android Place Picker Closes Immediately After Launch
Android: Display Image from Sd Card
Upgrade Realm in an Android Project
Does Broadcastreceiver.Onreceive Always Run in the UI Thread
Jar Mismatch! Fix Your Dependencies
Custom Attributes in Styles.Xml
Android Gcm: Same Sender Id for More Application
How to Display a Route Between Two Geocoords in Google Maps
Transparent Alertdialog Has Black Background
How to Resolve Java.Util.Zip.Zipexception
Android: Determine Active Input Method from Code
Android Music Seekbar Is Not Working (Idle)
How to Programmatically Clear Application Data