MissingSplitsManager

public interface MissingSplitsManager

com.google.android.play.core.missingsplits.MissingSplitsManager


Handles situations when the app is missing required split APKs.

Summary

Public methods

abstract boolean disableAppIfMissingRequiredSplits()

If a split APK is missing, the app is gracefully closed.

abstract boolean isMissingRequiredSplits()

Checks whether the app is missing a required split APK, without any side effects.

Public methods

disableAppIfMissingRequiredSplits

boolean disableAppIfMissingRequiredSplits ()

If a split APK is missing, the app is gracefully closed. Additionally, if the app was started by an explicit user action, the user is informed that the app is not installed correctly.

The method potentially has the following side effects:

  • Disables all non-activity app components, if a required split APK is missing.
  • Resets all non-activity app components to their default enabled state, if no required split APK is missing and all non-activity components are currently disabled (indicating that their state was manipulated by PlayCore).
  • Stops the current OS process (including explicitly cancelling all app tasks via finishAndRemoveTask()) and starts a new OS process for PlayCoreMissingSplitsActivity.

Typical usage in onCreate():

public class MyApplication extends android.app.Application {
   public void onCreate() {
     super.onCreate();

     if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
       // Skip rest of the initialization to prevent the app from crashing.
       return;
     }

     // Custom initialization logic, potentially relying on resources, native libraries and
     // other files that reside in split APKs.
   }
 }
 

Returns
boolean true if the app is missing some required splits, false otherwise

isMissingRequiredSplits

boolean isMissingRequiredSplits ()

Checks whether the app is missing a required split APK, without any side effects.

Typically should be used to manually skip initialization logic of custom ContentProvider implementations. The reason is that ContentProvider instances are initialized before the Application.

Typical usage in onCreate():

public class MyApplication extends android.content.ContentProvider {
   public void onCreate() {
     if (MissingSplitsManagerFactory.create(this).isMissingRequiredSplits()) {
       // Skip rest of the initialization to prevent the app from crashing.
       return;
     }

     // Custom initialization logic, potentially relying on resources, native libraries and
     // other files that reside in split APKs.
   }
 }
 

Returns
boolean true if the app is missing some required splits, false otherwise