Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

SplitInstallHelper

public class SplitInstallHelper
extends Object

java.lang.Object
   ↳ com.google.android.play.core.splitinstall.SplitInstallHelper


Helper class hosting utilities used to make information from split apks available to the rest of the app after the split is installed.

Summary

Public methods

static void loadLibrary(Context context, String libName)

Loads native library using classloader or full path if library is not available in the class path.

static void updateAppInfo(Context context)

Updates application info based on currently installed splits.

Inherited methods

From class java.lang.Object

Public methods

loadLibrary

void loadLibrary (Context context, 
                String libName)

Loads native library using classloader or full path if library is not available in the class path. This method should be used to load library from a newly installed split.

Note: For instant apps, updateAppInfo(Context) should be called first.

Parameters
context Context: application context

libName String: library name

Throws
UnsatisfiedLinkError

updateAppInfo

void updateAppInfo (Context context)

Updates application info based on currently installed splits.

Note #1: This method must be called after split is installed on O+ for instant apps, so that application components can see new resources and code from new splits.

Note #2: This method will update application info reference in application thread object.

Note #3: This method should only be called on O and OMR1 platform versions.

Example usage:

 // SplitInstallAPI callbacks
  public void onStateUpdate(SplitInstallSessionState splitInstallSessionState) {
    if (splitInstallSessionState.status() == SplitInstallSessionStatus.INSTALLED) {
      // Use SplitInstallHelper API on O+ to update application info after the splits are
      // installed.
      if (BuildCompat.isAtLeastO()) {
        // Updates app info with new split information making split artifacts available to the
        // app on subsequent requests.
        SplitInstallHelper.updateAppInfo(context);
      }
    }
  }
 
 

Parameters
context Context: application context