Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To switch between two of your own Android apps using implicit intent, follow these steps:

  1. Add an intent filter to the activity in the receiving app that you want to launch. In the AndroidManifest.xml file of the receiving app, add the following code snippet within the <activity> element:
<intent-filter>
    <action android:name="com.example.myapp.ACTION_SWITCH" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
  1. In the sending app, create an Intent object and set its action and package name to launch the receiving activity. For example:
val intent = Intent("com.example.myapp.ACTION_SWITCH")
intent.setPackage("com.example.otherapp")
startActivity(intent)
  1. Ensure that the receiving app is installed on the device, and that the package name in the Intent object matches the receiving app's package name.

  2. Run both apps and invoke the Intent from the sending app to launch the receiving activity.