diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 6e0b83f7e33cb..8f645c893a1cf 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -4416,11 +4416,20 @@ public final class ActivityThread extends ClientTransactionHandler if (localLOGV) Slog.v(TAG, "Creating service " + data.info.name); Application app = packageInfo.makeApplication(false, mInstrumentation); - java.lang.ClassLoader cl = packageInfo.getClassLoader(); + + final java.lang.ClassLoader cl; + if (data.info.splitName != null) { + cl = packageInfo.getSplitClassLoader(data.info.splitName); + } else { + cl = packageInfo.getClassLoader(); + } service = packageInfo.getAppFactory() .instantiateService(cl, data.info.name, data.intent); - final ContextImpl context = ContextImpl.getImpl(service + ContextImpl context = ContextImpl.getImpl(service .createServiceBaseContext(this, packageInfo)); + if (data.info.splitName != null) { + context = (ContextImpl) context.createContextForSplit(data.info.splitName); + } // Service resources must be initialized with the same loaders as the application // context. context.getResources().addLoaders(