{"id":225291,"date":"2024-05-29T16:27:20","date_gmt":"2024-05-29T16:27:20","guid":{"rendered":"https:\/\/michigandigitalnews.com\/index.php\/2024\/05\/29\/a-developers-roadmap-to-predictive-back-views\/"},"modified":"2025-06-25T17:18:32","modified_gmt":"2025-06-25T17:18:32","slug":"a-developers-roadmap-to-predictive-back-views","status":"publish","type":"post","link":"https:\/\/michigandigitalnews.com\/index.php\/2024\/05\/29\/a-developers-roadmap-to-predictive-back-views\/","title":{"rendered":"A Developer\u2019s Roadmap to Predictive Back (Views)"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<p>\nThe first milestone is to upgrade to Kotlin 1.8.0 or higher, which is required for other Predictive Back dependencies.<\/p>\n<div id=\"\">\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"Upgrade to Kotlin 1.8.0 or higher\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEg_Ek2FAu4xtj3kQEqLbutxWGSu2Ia1W85rM8QjxZ6S2woXClzsDmQIS5xEbvTjy78PmL1abA1OJ2lD2qbmC_NpsWfRP1fObeLs5rcJNPBOHK_GF_qV8Zrf3mKAb3Fjd2oOQNoKcLAgmIGUNn0VafZAUUaaEieNUc7rmWlFi8GHbHEwqumdX3v086ticOY\/s1600\/image7.png\" style=\"display: block; padding: 1em 0; text-align: center;\" width=\"70%\"\/><\/div>\n<h3>Back-to-home animation milestone<\/h3>\n<p>\nThe <a href=\"https:\/\/developer.android.com\/static\/images\/about\/versions\/13\/predictive-back-nav-home.gif\">back-to-home animation<\/a> is the keystone predictive back animation.\n<\/p>\n<p>\nTo get this animation, add <code>android:enableOnBackInvokedCallback=true <\/code>in your <code>AndroidManifest.xml <\/code>for your root activity if you are a multi-activity app (see <a href=\"https:\/\/developer.android.com\/guide\/navigation\/custom-back\/predictive-back-gesture#opt-activity-level\">per-activity opt-in<\/a>) or at the application level if you are a single-activity app. After this, you\u2019ll see both the back-to-home animation and a cross-task animation where applicable, which are visible to users in Android 15+ and behind a developer option in Android 13 and 14.\n<\/p>\n<p>\nIf you are intercepting back events in your root activity (e.g. MainActivity), you can continue to do so but you\u2019ll need to use supported APIs and you won\u2019t get the back-to-home animation. For this reason, we generally recommend you only intercept back events for UI logic; for example, to show a dialog asking the user to save before they quit.\n<\/p>\n<p>\nSee the <a href=\"https:\/\/developer.android.com\/guide\/navigation\/custom-back\/predictive-back-gesture\">Add support for the predictive back gesture<\/a> guide for more details.\n<\/p>\n<p>    <image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"Milestone grid\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjnaFO28cHUQ7BK81DDrseytWUSxAAMJso-PE8UH2MqdqDzNBICfDSHOi93tu9ODSeXejQ24YO8UrWbNpDCfd4HsT6SEYWTOSbY3t6PDvc_v7f2SI5RT5V0-GvXioil2dVzpe1UAlCqLoVP1FQkRaUDsp1ZgHiFdT3rBrEbT1riKxk0-IosARR92EBUKpw\/s1600\/image4\" style=\"display: block; padding: 1em 0; text-align: center;\" width=\"100%\"\/><\/div>\n<p><\/image><\/p>\n<h3>Migrate all activities milestone<\/h3>\n<p>\nIf you are a multi-activity app, you\u2019ll need to opt-in and handle back events within those activities too to get a system controlled <a href=\"https:\/\/developer.android.com\/guide\/navigation\/custom-back\/support-animations\">cross-activity animation<\/a>. Learn more about <a href=\"https:\/\/developer.android.com\/guide\/navigation\/custom-back\/predictive-back-gesture#opt-activity-level\">per-activity opt-in<\/a>, available for devices running Android 14+. The cross-activity animation is visible to users in Android 15+ and behind a developer option in Android 13 and 14.\n<\/p>\n<p>\nCustom cross activity animations are also available with <a href=\"https:\/\/developer.android.com\/guide\/navigation\/custom-back\/support-animations#custom-activity\">overrideActivityTransition<\/a>.\n<\/p>\n<p>    <image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"Milestone grid\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjAKyCH4eZFXScFmcVqtD-sl1udwcoSdk9xzSBYbZYoGHZGPpt7jiApk02I6_OURtke5_VQej4dPCCgNBzn-Ac-KCyyz4ZjOq_cxmk7VsOGiPFCj725VuNlKOA8FDljwrodw15b9kGJcAMsRVsKMiUGRTPBJ8zND0uaSy8EX5DN5vh3-eW28iE1RYXxgTY\/s1600\/image1.png\" style=\"display: block; padding: 1em 0; text-align: center;\" width=\"100%\"\/><\/div>\n<p><\/image><\/p>\n<h3>Fragment milestone<\/h3>\n<p>\nNext, you\u2019ll want to focus on your fragment animations and transitions. This requires updating to AndroidX <a href=\"https:\/\/developer.android.com\/jetpack\/androidx\/releases\/fragment#1.7.0\">fragment 1.7.0<\/a> and <a href=\"https:\/\/developer.android.com\/jetpack\/androidx\/releases\/transition#1.5.0\">transition 1.5.0<\/a> or later and using Animator or AndroidX Transitions. Assuming these requirements are met, your existing fragment animations and transitions will animate in step with the back gesture. You can also use <a href=\"https:\/\/m2.material.io\/develop\/android\/theming\/motion\">material motion<\/a> with fragments. Most material motions support predictive back as of <a href=\"https:\/\/github.com\/material-components\/material-components-android\/releases\/tag\/1.12.0-alpha02\">1.12.02-alpha02<\/a> or higher, including MaterialFadeThrough, MaterialSharedAxis and MaterialFade.\n<\/p>\n<p>\nDon\u2019t strive to make your fragment transitions look like the system\u2019s cross-activity transition. We recommend <a href=\"https:\/\/developer.android.com\/design\/ui\/mobile\/guides\/patterns\/predictive-back#full-screen-surfaces\">this full screen surface transition<\/a> instead.\n<\/p>\n<p>\nLearn more about <a href=\"https:\/\/developer.android.com\/guide\/navigation\/custom-back\/support-animations#fragments\">Fragments and Predictive Back<\/a>.\n<\/p>\n<p>      <image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"Milestone grid\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhdclWFJr2rvUcFzkKQY9smTFCF6ahrmhN7DysRqnNSYy-H_0D64Q4WyLAW1XCBviLE0edwI9mDLbMgOvrfGhPS6srDug-zZaah4498raFn1vUg8u5kHPUzYNh19O38TM_oPCdf8JnYtJYUE6hDPPxKms44soWUUVCXdtJBJ_H2lBzj0Hvup0Hbztw5jxI\/s1600\/image2.png\" style=\"display: block; padding: 1em 0; text-align: center;\" width=\"100%\"\/><\/div>\n<h3>Material Components milestone<\/h3>\n<p>\nFinally, you\u2019ll want to take advantage of the Material Component View animations available for Predictive Back. Learn more about <a href=\"https:\/\/github.com\/material-components\/material-components-android\/blob\/master\/docs\/foundations\/PredictiveBack.md#predictive-back-material-components\">available components<\/a>.\n<\/p>\n<p>              <image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"Milestone grid\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjtpbwmcn_XqUAm3xvpF8OAC9dR-yK9iM_VDligFL6x1UOpzam8D14kSExzYjl0x2MgPQpUNnr2iNsxoq678aM_SoUzUzMu3TdMdDqwV9ui6r139ukGbV50oY8lJTUFMnzCXERj5ztoMZoxIEU0iVZ2nfM4k6U6qPvj_Myw0w3FZDdKg2TWo2Y2is-gthk\/s1600\/image5.png\" style=\"display: block; padding: 1em 0; text-align: center;\" width=\"100%\"\/><\/div>\n<p>\nAfter this, you\u2019ve completed your quest to support Predictive Back animations in your view based app.\n<\/p>\n<h3>[Optional] AndroidX Transitions milestone<\/h3>\n<p>\nIf you\u2019re up for more, you might also ensure your AndroidX transitions are supported with Predictive Back. Read more about AndroidX Transitions and the Predictive Back <a href=\"https:\/\/developer.android.com\/guide\/navigation\/custom-back\/support-animations#progress-api\">Progress APIs<\/a>.\n<\/p>\n<p>                <image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"Milestone grid\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiEXSC_3qTyw_GKmQXvNWKA03ZOiSc06-Bzo-i0uSE9DWgAI39RNqpRoQ1sODcw_6NnIsrofeI6beHsSrbFHEog6qpYGF5LIlZX2mbgwRiglKoSwk0ZzDbw15l4pcpCj_sD4TeEITRDyq7a76ykK3dDEzRbOJ6mRjCKeTZRHjupxl6ioTSk5kmUpieu3Xg\/s1600\/image8.png\" style=\"display: block; padding: 1em 0; text-align: center;\" width=\"100%\"\/><\/div>\n<h3>Other Resources<\/h3>\n<p><\/image><\/image><\/p>\n<p><\/image><\/div>\n<p>[ad_2]<br \/>\n<br \/><a href=\"http:\/\/android-developers.googleblog.com\/2024\/05\/a-developers-roadmap-to-predictive-back.html\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] The first milestone is to upgrade to Kotlin 1.8.0 or higher, which is required for other Predictive Back dependencies. Back-to-home animation milestone The back-to-home<\/p>\n","protected":false},"author":1,"featured_media":225292,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[146],"tags":[],"_links":{"self":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/225291"}],"collection":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/comments?post=225291"}],"version-history":[{"count":0,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/225291\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media\/225292"}],"wp:attachment":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media?parent=225291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/categories?post=225291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/tags?post=225291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}