Skip to content

Instantly share code, notes, and snippets.

View husaynhakeem's full-sized avatar

Husayn Hakeem husaynhakeem

View GitHub Profile
class ListActivity : AppCompatActivity() {
private val splitListener = Consumer<List<SplitInfo>> { splitInfoList ->
// React to a split change
}
override fun onStart() {
super.onStart()
SplitController
.getInstance()
val splitController = SplitController.getInstance()
if (!splitController.isSplitSupported()) {
// Split is not supported on this device
}
<resources xmlns:window="http://schemas.android.com/apk/res-auto">
<SplitPairRule
window:finishPrimaryWithSecondary="true"
window:finishSecondaryWithPrimary="true"
window:splitRatio="0.4">
<SplitPairFilter
window:primaryActivityName=".list.ListActivity"
window:secondaryActivityName=".details.DetailsActivity" />
</SplitPairRule>
</resources>
<resources xmlns:window="http://schemas.android.com/apk/res-auto">
<SplitPairRule
<!-- split rule config option -->
>
<SplitPairFilter
window:primaryActivityName=".list.ListActivity"
window:secondaryActivityName=".details.DetailsActivity" />
<SplitPairFilter
window:primaryActivityName=".details.DetailsActivity"
window:secondaryActivityName=".share.ShareActivity" />
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:window="http://schemas.android.com/apk/res-auto">
<!-- Other rules -->
<SplitPlaceholderRule
window:placeholderActivityName=".details.DetailsPlaceholderActivity"
window:splitRatio="0.4">
<ActivityFilter window:activityName=".list.ListActivity" />
</SplitPlaceholderRule>
</resources>
dependencies {
// Other app dependencies
implementation "androidx.window:window:1.0.0"
}
class ActivityEmbeddingSampleApplication : Application() {
override fun onCreate() {
super.onCreate()
SplitController.initialize(this, R.xml.split_configuration)
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:window="http://schemas.android.com/apk/res-auto">
<SplitPairRule
window:splitRatio="0.4">
<SplitPairFilter
window:primaryActivityName=".list.ListActivity"
window:secondaryActivityName=".details.DetailsActivity" />
</SplitPairRule>
</resources>
class RemoteViewInteropWidget : GlanceAppWidget() {
@Composable
override fun Content() {
Column {
Text(text = "Above remote views")
val context = LocalContext.current
AndroidRemoteViews(remoteViews = RemoteViewWidget(context))
class SizeSingleWidget : GlanceAppWidget() {
override val sizeMode: SizeMode = SizeMode.Single
// Remainder of the widget's implementation
}