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- 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
How to Connect to a Specific Wi-Fi Network in Android Programmatically
How to Update Recyclerview Adapter Data
How to Get Zoom Functionality For Images
How to Use Recyclerview Inside Nestedscrollview
Android Studio 3.5 Refactor Issue
Getting an Issue While Checking the Dynamically Generated Checkbox Through List View
How to Validate an E-Mail Address
How to Detect Orientation Change in Layout in Android
Fullscreen Activity in Android
Changing Locale Within the App Itself
Android Action_Image_Capture Intent
How to Completely Uninstall Android Studio from Windows(V10)
Android Broadcastreceiver on Startup - Keep Running When Activity Is in Background
Background Task, Progress Dialog, Orientation Change - Is There Any 100% Working Solution