Activity Embedding in Android

 

codeblogs

Introducing Activity Embedding

Use Case: List/Details Pattern

List/Details with Activity Embedding

  1. Add the WindowManager dependency to the app’s build.gradle file. Activity embedding was introduced in version 1.0.0-beta03, so make sure to use a version as recent as this one at minimum.


dependencies {
// Other app dependencies
implementation "androidx.window:window:1.0.0"
}

Adding a Placeholder

Back Navigation

Multiple Activities

Split Rule Configuration Options

Listening to Split Events

Split Support

Conclusion

  • Use Activity embedding in your Activity based app to support multi-pane layouts, allowing your users to see/do/experience more on large screens by making use of the extra screen real estate.
  • Provide a split configuration file that defines the split rules the system uses to handle embedding Activities in your app.
  • Define how embedded Activities should launch other Activities, and control how the system finishes them.
  • Customize split rules by using the supported options which include splitRatiominSplitWidth and clearTop.
  • Register a split listener to receive updates on active splits. Don’t forget to unregister it!
  • Check for split support on devices at runtime using SplitController.isSplitSupported().
  • Activity embedding only works if the split rule defines splitRatio.
  • Updating finishPrimaryWithSecondary and finishSecondaryWithPrimary seemingly has no effect on the finishing behavior of Activities in the primary and secondary containers. (Potential bug)
  • If Activities that support embedding are run in a task that belongs to another app, then embedding will not work for them.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.