implementation 'com.google.android.play:core:1.6.3'
To make your module downloadable on demand add the following in the
app-module's build.gradle,
Slide 36
Slide 36 text
Pro Tip #1
● Treat the dynamic-module as the individual app itself
Slide 37
Slide 37 text
dependencies {
.....
api 'androidx.appcompat:appcompat:1.0.2'
api 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.play:core:1.6.1'
}
In the manifest of the app’s module,
Slide 38
Slide 38 text
This is our project
Slide 39
Slide 39 text
dependencies {
.....
api 'androidx.appcompat:appcompat:1.0.2'
api 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.play:core:1.6.1'
}
In the manifest of the app’s module,
Slide 40
Slide 40 text
dependencies {
.....
api 'androidx.appcompat:appcompat:1.0.2'
api 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.play:core:1.6.1'
}
In the manifest of the app’s module,
Slide 41
Slide 41 text
Let's learn how to make the dynamic-feature downloadable
from the app's module.
Slide 42
Slide 42 text
class MainActivity : AppCompatActivity() {
lateinit var splitInstallManager: SplitInstallManager
lateinit var request: SplitInstallRequest
val DYNAMIC_FEATURE = "news_feature"
override fun onCreate(savedInstanceState: Bundle?) {
....
}
}
In App’s MainActivity
Slide 43
Slide 43 text
override fun onCreate(savedInstanceState: Bundle) {
....
initDynamicModules()
}
private fun initDynamicModules() {
splitInstallManager = SplitInstallManagerFactory.create(this)
request = SplitInstallRequest
.newBuilder()
.addModule(DYNAMIC_FEATURE)
.build();
}
In App’s MainActivity
Slide 44
Slide 44 text
Implement Clicks :)
Slide 45
Slide 45 text
In App’s MainActivity
override fun onCreate(savedInstanceState: Bundle) {
........
buttonClick.setOnClickListener {
if (!isDynamicFeatureDownloaded(DYNAMIC_FEATURE)) {
downloadFeature()
} else {
buttonDeleteNewsModule.visibility = View.VISIBLE
buttonOpenNewsModule.visibility = View.VISIBLE
}
}
}
Slide 46
Slide 46 text
In App’s MainActivity
private fun isDynamicFeatureDownloaded(feature: String): Boolean =
splitInstallManager.installedModules.contains(feature)