I need some help about accessing dynamic module's asset. I have base application and I have added new dynamic module in this apps called as "dlc_module". this dynamic module only have asset file and what I want to do is accessing module's asset from base apps.
import com.example.android.MainActivity; //this MainActivity class
public class ModuleDownloader
{
public static void loadAndLaunchModule()
{
String moduleName = "dlc_module";
if (splitinstallManager.getInstalledModules().contains(moduleName))
{
onSuccessfulLoad(moduleName);
return;
}
SplitInstallRequest splitInstallRequest = SplitInstallRequest.newBuilder()
.addModule(moduleName)
.build();
splitinstallManager.startInstall(splitInstallRequest).addOnSuccessListener(new OnSuccessListener<Integer>() {
@Override
public void onSuccess(Integer integer) {}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {}
});
}
private static void onSuccessfulLoad()
{
copyResources();
}
public static void copyResources()
{
String packageName = "com.example.android.dlc_module";// module's package
try
{
AssetManager assetmodule = MainActivity.getActivityContext().createPackageContext(packageName, 0).getAssets();
}catch (Exception e)
{
e.printStackTrace();
}
}
}
my current process is already in copyResources() but when tried to execute createPackageContext, the process always ends in statement catch, could you please help me on this?
Comments
Post a Comment