imi*_*imi 2 java android android-app-bundle
通过内部测试,我可以下载动态功能模块。成功下载后,我正在使用包名称打开动态模块中的活动,但我遇到了类未找到异常。我检查了 APK 大小,但大小没有增加。下面是我的代码。请帮忙
下面是我下载模块的代码。我使用的是 Playstore 中提供的内部测试。
public void loadFeatureTwo() {
// Builds a request to install the feature1 module
SplitInstallRequest request =
SplitInstallRequest
.newBuilder()
// You can download multiple on demand modules per
// request by invoking the following method for each
// module you want to install.
.addModule("feature2")
.build();
// Begin the installation of the feature1 module and handle success/failure
splitInstallManager
.startInstall(request)
.addOnSuccessListener(new OnSuccessListener<Integer>() {
@Override
public void onSuccess(Integer integer) {
// Module download successful
/* Intent intent = new Intent().setClassName(getPackageName(), "com.bapspatil.feature2.FeatureTwoActivity");
startActivity(intent);*/
Toast.makeText(getApplicationContext(), "successfully download feature2: ", Toast.LENGTH_LONG).show();
try {
Intent myIntent = new Intent(MainActivity.this, Class.forName("com.bapspatil.feature2.FeatureTwoActivity"));
startActivity(myIntent);
} catch (Exception e) {
e.printStackTrace();
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
// Module download failed; handle the error here
Toast.makeText(getApplicationContext(), "Couldn't download feature: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1376 次 |
| 最近记录: |