ActivityCompat
Stay organized with collections
Save and categorize content based on your preferences.
This interface is deprecated.Starting December 2025, Instant Apps cannot be published through Google Play, and all Google
Play services Instant APIs will no longer work. To continue optimizing for user growth, we
encourage developers to refer users to their regular app or game, and using deeplinks to
redirect them to specific journeys or features when relevant.
A helper for accessing features in Activity
in a
backwards compatible fashion. Construct this by using InstantApps.getActivityCompat(Activity)
.
This helper augments the included methods with data on instant apps.
Public Methods
public abstract ComponentName
getCallingActivity
()
Gets the ComponentName
of the activity that launched the intent to start this activity. This may be an
activity in an installed app or an instant app.
Returns
- the component name of the activity that started the activity, or null
public abstract String
getCallingPackage
()
Gets the package name of the app that launched the intent to start this activity.
This may be the package name of an installed app or an instant app.
Returns
- the package name of the app that started this activity, or null
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-21 UTC."],[[["\u003cp\u003e\u003ccode\u003eActivityCompat\u003c/code\u003e helps access features in \u003ccode\u003eActivity\u003c/code\u003e with backwards compatibility and added instant app data.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to identify the calling activity and package, which could be from an installed app or an instant app.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetCallingActivity()\u003c/code\u003e returns the \u003ccode\u003eComponentName\u003c/code\u003e of the activity that started the current activity.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetCallingPackage()\u003c/code\u003e returns the package name of the app that started the current activity.\u003c/p\u003e\n"]]],["`ActivityCompat` is a helper for accessing `Activity` features compatibly, augmented with instant app data. Key actions include retrieving the `ComponentName` via `getCallingActivity()`, which identifies the activity that initiated the current activity. Another core function is `getCallingPackage()`, which retrieves the package name of the app that launched the current activity, applicable to both installed and instant apps. Both methods may return `null` if no initiating activity or package is found.\n"],null,["# ActivityCompat\n\npublic interface **ActivityCompat** \n**This interface is deprecated.** \n\nStarting December 2025, Instant Apps cannot be published through Google Play, and all Google\nPlay services Instant APIs will no longer work. To continue optimizing for user growth, we\nencourage developers to refer users to their regular app or game, and using deeplinks to\nredirect them to specific journeys or features when relevant.\n\nA helper for accessing features in [Activity](//developer.android.com/reference/android/app/Activity.html) in a\nbackwards compatible fashion. Construct this by using [InstantApps.getActivityCompat(Activity)](/android/reference/com/google/android/gms/instantapps/InstantApps#getActivityCompat(android.app.Activity)).\n\nThis helper augments the included methods with data on instant apps. \n\n### Public Method Summary\n\n|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [ComponentName](//developer.android.com/reference/android/content/ComponentName.html) | [getCallingActivity](/android/reference/com/google/android/gms/instantapps/ActivityCompat#getCallingActivity())() Gets the [ComponentName](//developer.android.com/reference/android/content/ComponentName.html) of the activity that launched the intent to start this activity. |\n| abstract [String](//developer.android.com/reference/java/lang/String.html) | [getCallingPackage](/android/reference/com/google/android/gms/instantapps/ActivityCompat#getCallingPackage())() Gets the package name of the app that launched the intent to start this activity. |\n\nPublic Methods\n--------------\n\n#### public abstract [ComponentName](//developer.android.com/reference/android/content/ComponentName.html)\n**getCallingActivity** ()\n\nGets the [ComponentName](//developer.android.com/reference/android/content/ComponentName.html)\nof the activity that launched the intent to start this activity. This may be an\nactivity in an installed app or an instant app. \n\n##### Returns\n\n- the component name of the activity that started the activity, or null \n\n##### See Also\n\n- [Activity.getCallingActivity()](//developer.android.com/reference/android/app/Activity.html#getCallingActivity()) \n\n#### public abstract [String](//developer.android.com/reference/java/lang/String.html) **getCallingPackage** ()\n\nGets the package name of the app that launched the intent to start this activity.\nThis may be the package name of an installed app or an instant app. \n\n##### Returns\n\n- the package name of the app that started this activity, or null \n\n##### See Also\n\n- [Activity.getCallingPackage()](//developer.android.com/reference/android/app/Activity.html#getCallingPackage())"]]