Stay organized with collections
Save and categorize content based on your preferences.
SplitCompat
public
class
SplitCompat
extends Object
Enables immediate access to code and resources of split APKs installed through SplitInstallManager
.
To learn more, read Immediately
access modules.
Summary
Public methods |
static
boolean
|
install(Context context)
Emulates installation of split APKs to allow immediate access to their code and resources.
|
static
boolean
|
installActivity(Context context)
Emulates installation of a split APK to allow immediate access to a given activity.
|
Inherited methods |
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public methods
install
public static boolean install (Context context)
Emulates installation of split APKs to allow immediate access to their code and resources.
To use this method, you must invoke it at app startup with the app context (see SplitCompatApplication
). If you call this method, you should also call installActivity(Context)
on any activities inside the dynamic feature module you've installed.
To learn more, read Invoke
SplitCompat at runtime. Additionally, to learn how to gain immediate access to language
resources your app has downloaded, read Access
downloaded language resources.
Parameters |
context |
Context |
Returns |
boolean |
whether the split install was successful. This method returns false on platform
versions lower than Android 5.0 (API level 21), which do not support split APKs.
|
installActivity
public static boolean installActivity (Context context)
Emulates installation of a split APK to allow immediate access to a given activity.
To use this API, use the following pattern:
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
SplitCompat.installActivity(this);
}
To use this API, you also need to first call install(Context)
with the application context
at app startup.
Parameters |
context |
Context |
Returns |
boolean |
whether split install was successful. This method returns false on platform
versions lower than Android 5.0 (API level 21), which do not support split APKs. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# SplitCompat\n\nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nSplitCompat\n===========\n\n\n`\npublic\n\n\nclass\nSplitCompat\n`\n\n\n`\n\nextends `[Object](https://developer.android.com/reference/java/lang/Object.html)`\n\n\n`\n\n`\n\n\n`\n\n|---|------------------------------------------------------|\n| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||\n| ↳ | com.google.android.play.core.splitcompat.SplitCompat |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nEnables immediate access to code and resources of split APKs installed through [SplitInstallManager](../../../../../../../reference/com/google/android/play/core/splitinstall/SplitInstallManager.html).\n\nTo learn more, read [Immediately\naccess modules](https://d.android.com/guide/playcore/dynamic-delivery#access_downloaded_modules).\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static boolean` | ` `[install](../../../../../../../reference/com/google/android/play/core/splitcompat/SplitCompat.html#install(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Emulates installation of split APKs to allow immediate access to their code and resources. |\n| ` static boolean` | ` `[installActivity](../../../../../../../reference/com/google/android/play/core/splitcompat/SplitCompat.html#installActivity(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Emulates installation of a split APK to allow immediate access to a given activity. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` boolean` | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`\u003c?\u003e` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` `[String](https://developer.android.com/reference/java/lang/String.html) | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||\n\nPublic methods\n--------------\n\n### install\n\n```\npublic static boolean install (Context context)\n```\n\nEmulates installation of split APKs to allow immediate access to their code and resources.\n\nTo use this method, you must invoke it at app startup with the app context (see [SplitCompatApplication](../../../../../../../reference/com/google/android/play/core/splitcompat/SplitCompatApplication.html)). If you call this method, you should also call [installActivity(Context)](../../../../../../../reference/com/google/android/play/core/splitcompat/SplitCompat.html#installActivity(android.content.Context)) on any activities inside the dynamic feature module you've installed.\n\nTo learn more, read [Invoke\nSplitCompat at runtime](https://d.android.com/guide/playcore/dynamic-delivery#invoke_splitcompat_at_runtime). Additionally, to learn how to gain immediate access to language\nresources your app has downloaded, read [Access\ndownloaded language resources](https://d.android.com/guide/playcore/dynamic-delivery#access_lang_resources).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|------------------|\n| `context` | `Context` \u003cbr /\u003e |\n\n| Returns ||\n|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `boolean` | whether the split install was successful. This method returns `false` on platform versions lower than Android 5.0 (API level 21), which do not support split APKs. \u003cbr /\u003e |\n\n### installActivity\n\n```\npublic static boolean installActivity (Context context)\n```\n\nEmulates installation of a split APK to allow immediate access to a given activity.\n\nTo use this API, use the following pattern:\n\n```\n protected void attachBaseContext(Context base) {\n super.attachBaseContext(base);\n SplitCompat.installActivity(this);\n }\n \n```\n\nTo use this API, you also need to first call [install(Context)](../../../../../../../reference/com/google/android/play/core/splitcompat/SplitCompat.html#install(android.content.Context)) with the application context\nat app startup.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|------------------|\n| `context` | `Context` \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `boolean` | whether split install was successful. This method returns `false` on platform versions lower than Android 5.0 (API level 21), which do not support split APKs. \u003cbr /\u003e |\n\n| Throws ||\n|-------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|\n| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if SplitCompat was not called at startup on application context |"]]