{"id":4603,"date":"2018-12-30T08:31:14","date_gmt":"2018-12-30T08:31:14","guid":{"rendered":"https:\/\/www.gtechbooster.com\/?p=4603"},"modified":"2023-04-01T01:38:05","modified_gmt":"2023-04-01T01:38:05","slug":"foldable-is-here-users-and-developers","status":"publish","type":"post","link":"https:\/\/gtechbooster.com\/foldable-is-here-users-and-developers\/","title":{"rendered":"Foldable is here, Users and Developers"},"content":{"rendered":"\n<p>Within the next few months, mobile devices\nwill be introduced with new form factors. First of these form factors\nthat will be offered in the market are foldable phones. Soon, various\ntypes of form factor devices will be released.<\/p>\n\n\n\n<div class=\"gtech-migrated-from-ad-inserter-placement-2\" style=\"text-align: center;\" id=\"gtech-3009417387\"><div style=\"margin-right: auto;margin-left: auto;text-align: center;\" id=\"gtech-2604625365\"><a data-bid=\"1\" data-no-instant=\"1\" href=\"https:\/\/gtechbooster.com\/linkout\/17207\" rel=\"noopener\" class=\"notrack\" aria-label=\"26001\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gtechbooster.com\/media\/2023\/01\/26001.jpeg\" alt=\"\"  srcset=\"https:\/\/gtechbooster.com\/media\/2023\/01\/26001.jpeg 1024w, https:\/\/gtechbooster.com\/media\/2023\/01\/26001-768x960.jpeg 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" width=\"500\" height=\"625\"  style=\"display: inline-block;\" \/><\/a><\/div><\/div><p>For upcoming new form factors on devices,\n the teams at Samsung and at Google Android hope that app developers\nwill look first at this design guide as the first step.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">App continuity<\/h5>\n\n\n\n<p>Users will be able to control multiple\ndisplays on one mobile device. The apps will be displayed on different\nscreens to suit the user&#8217;s preferences, as they will be switched between\n the screens. As a result, apps are needed to be prepared to switch\nbetween multiple screens using different screen attributes (resolutions,\n densities, and etc). <\/p>\n\n\n\n<p>Users also can unfold the device to have\nan immersive experience with the current task. Therefore when user\nunfolded the device, the current task must continue seamlessly into an\nunfolded display.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Multi-window<\/h5>\n\n\n\n<p>A bigger screen real estate on foldable devices renders multi-tasking into an engaging experience.<\/p>\n\n\n\n<p>Android 7.0 supports displaying more than one app at the same time. In addition, when switching to a large screen such as a foldable phone case, users can use two or more apps on split-screen mode. There may be instances that the app may stop functioning whenever moving the focus from one to the other. To mitigate this, you will need to check the documentation on supporting the app with multi-resume in multi-active window mode of the device. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Technical<\/h2>\n\n\n\n<p>To make the best experience for foldable devices make sure your apps are ready to work seamlessly between two displays and be active in multi-window mode.<\/p>\n\n\n\n\n\n<h5 class=\"wp-block-heading\">App continuity<\/h5>\n\n\n\n<p>Users unfold the device to have an immersive experience with the current task.<\/p>\n\n\n\n<p>When unfolded, the current task must continue seamlessly into an unfolded display and vice-versa.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Multi-window<\/h5>\n\n\n\n<p>A bigger screen real estate on foldable devices renders multi-tasking into an engaging experience.<\/p>\n\n\n\n<p>Android 7.0 and higher supports\ndisplaying more than one app at the same time. In addition, when\nswitching to a large screen such as a foldable phone case, users can use\n two or more apps on split-screen mode. There may be instances that the\napp may stop functioning whenever moving the focus from one to the\nother. To mitigate this, you will need to check the documentation on\nsupporting the app with multi-resume in multi-active window mode of the\ndevice.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">App continuity<\/h4>\n\n\n\n\n\n<p>Folding\/unfolding triggers a configuration change for <em>smallestScreenSize, screenSize<\/em> and <em>screenLayout<\/em>.<\/p>\n\n\n\n<p>This configuration change is similar with\napps that are configured in multi-window mode. Even apps that does not\nsupport multi-window can be resized when a device gets folded or\nunfolded.<\/p>\n\n\n\n<p>Whenever a configuration change occurs, the default case is that the whole activity is destroyed and recreated.<\/p>\n\n\n\n<p>It is important to restore the previous\nstate when the activity is restarted. To properly save and restore the\nprevious state you can use <em>onSaveInstanceState()<\/em> and <em>ViewModel<\/em> object.<\/p>\n\n\n\n<p>You can save the state in <em>onSaveInstancesState()<\/em> before your activity is destroyed and restore in <em>onCreate()<\/em> or <em>onRestoreInstanceState()<\/em>.<\/p>\n\n\n\n<p>If you want handling configuration change without restart, you need to add an <em>android:configChanges<\/em> attribute to your manifest with at least these values below.<\/p>\n\n\n\n<p>With this attribute, you will need to manually update your view layout and reload resources in <em>onConfigurationChaged()<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;activity\n    android:name=\".MyActivity\"\n    android:configChanges=\"screenSize|smallestScreenSize|screenLayout\"\n\/><\/code><\/pre>\n\n\n\n<p>Do not call <em>finish()<\/em> or kill the process by itself in the activity\u2019s <em>onDestroy()<\/em>. This will cause the app to close when a device gets folded or unfolded.<\/p><div class=\"gtech-mid-cont\" style=\"text-align: center;\" id=\"gtech-241940994\"><div style=\"margin-right: auto;margin-left: auto;text-align: center;\" id=\"gtech-2604169122\"><a data-bid=\"1\" data-no-instant=\"1\" href=\"https:\/\/gtechbooster.com\/linkout\/17207\" rel=\"noopener\" class=\"notrack\" aria-label=\"26001\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gtechbooster.com\/media\/2023\/01\/26001.jpeg\" alt=\"\"  srcset=\"https:\/\/gtechbooster.com\/media\/2023\/01\/26001.jpeg 1024w, https:\/\/gtechbooster.com\/media\/2023\/01\/26001-768x960.jpeg 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" width=\"500\" height=\"625\"  style=\"display: inline-block;\" \/><\/a><\/div><\/div>\n\n\n\n<p>Please refer to the detail in <a href=\"https:\/\/developer.android.com\/guide\/topics\/resources\/runtime-changes\">Android developer guide<\/a><br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Multi-resume<\/h4>\n\n\n\n<h3 class=\"wp-block-heading\">What is multi-resume ?<\/h3>\n\n\n\n<p>An app that is running in multi-window will be paused when not active in the previous Android versions.<\/p>\n\n\n\n<p>With Android P (Pie), it provides a\nmulti-resume functionality for all visible top activities if the app and\n OEM (Original Equipment Manufacturer) opts in.<\/p>\n\n\n\n<p>Multi-resume is expected to become a mandatory behavior in Android Q.<\/p>\n\n\n\n\n\n<h3 class=\"wp-block-heading\">How can I make the app run in multi-resume?<\/h3>\n\n\n\n<p>Set the manifest flag to keep the app in a\nresumed state. This will allow the app to have resumed state even when\nit is not the topmost app.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code Block 1 Manifest flag<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;application>\n  &lt;meta-data\n    android:name=\"android.allow_multiple_resumed_activities\"\n    android:value=\u201dtrue\u201d \/>\n  &lt;activity ... \/>\n&lt;\/application><\/code><\/pre>\n\n\n\n<p>\n   Note\n    <\/p>\n\n\n\n<p>More than one activity of the same app can be resumed.<\/p>\n\n\n\n<p>Caution with singletons storing the resumed activity, including in frameworks you depend on<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Other practices<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">Maximum aspect ratio<\/h4>\n\n\n\n<p>The cover display will have a long (21:9) aspect ratio.<\/p>\n\n\n\n<p>So the application needs to handle a maximum aspect ratio to fill the entire screen.<\/p>\n\n\n\n<p>The public guide is found in the <a href=\"https:\/\/developer.android.com\/guide\/practices\/screens-distribution#MaxAspectRatio\">Android developer site<\/a>:<\/p>\n\n\n\n<p>In the guideline, you can choose the following options to support aspect ratio.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li> 1. Declare the target SDK version Apps that targets Android 8.0 (API level 26) or higher, they will fill the entire screen. <\/li><li> 2. Declare the <em>resizeableActivity<\/em> If the activity is resizable, your Activity will fill the entire screen. <strong>Code Block 2 Set attribute in your manifest&#8217;s <code>&lt;activity&gt;<\/code> or <code>&lt;application&gt;<\/code> element <\/strong>\n     <code>android:resizeableActivity=[\"true\" | \"false\"]<\/code>\n     <\/li><li> 3. Declare a max aspect ratio For Android 7.1 and lower, add a &lt;meta-data&gt; element named android.max_aspect in the &lt;application&gt; element. <strong>Code Block 3 meta-data android.max_aspect<\/strong>\n     <code>&lt;!-- Render on full screen up to screen aspect ratio of 2.4 --&gt;\n&lt;!-- Use a letterbox on screens larger than 2.4 --&gt;\n&lt;meta-data android:name=\"android.max_aspect\" android:value=\"2.4\" \/&gt;<\/code>\n     <\/li><\/ol>\n\n\n\n<p>\n   Note\n    <\/p>\n\n\n\n<p>If an app does not support a long aspect ratio (9:21), it may not\n be resized properly when unfolded in emulator environment. Please make\nsure the app support a long aspect ratio first before testing folding\nand unfolding.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Optimized layouts for cover display and main display<\/h5>\n\n\n\n<p>Now the app will run in both displays even with different sizes.<\/p>\n\n\n\n<p>We recommend adding a separate resource folder to show more rich and clear content.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">How to optimize layouts<\/h5>\n\n\n\n<p>Refer to the <a href=\"https:\/\/developer.android.com\/guide\/practices\/screens_support\">following link to get the default information about separate resource folder.<\/a><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Reference display configuration<\/h5>\n\n\n\n<p>See the foldable device configurations below for each display.<\/p>\n\n\n\n<figure class=\"wp-block-table alignwide\"><table class=\"\"><thead><tr><td><\/td><th>Cover display<\/th><th>Main display<\/th><\/tr><\/thead><tbody><tr><td>smallest width<\/td><td>320 dp<\/td><td>585 dp<\/td><\/tr><tr><td>screen size<\/td><td>840 x 1960<\/td><td>1536 x 2152<\/td><\/tr><tr><td>screen layout<\/td><td>SCREENLAYOUT_SIZE_NORMAL<br> SCREENLAYOUT_LONG_YES<\/td><td>SCREENLAYOUT_SIZE_LARGE<br> SCREENLAYOUT_LONG_NO<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">More Information<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li> <a href=\"https:\/\/developer.samsung.com\/galaxy\/foldable\">Galaxy Foldables<\/a> <\/li><\/ul>\n<div class=\"gtech-end-cont\" id=\"gtech-2961739581\"><div style=\"margin-right: auto;margin-left: auto;text-align: center;\" id=\"gtech-1903373097\"><a data-bid=\"1\" data-no-instant=\"1\" href=\"https:\/\/gtechbooster.com\/linkout\/17207\" rel=\"noopener\" class=\"notrack\" aria-label=\"26001\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gtechbooster.com\/media\/2023\/01\/26001.jpeg\" alt=\"\"  srcset=\"https:\/\/gtechbooster.com\/media\/2023\/01\/26001.jpeg 1024w, https:\/\/gtechbooster.com\/media\/2023\/01\/26001-768x960.jpeg 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" width=\"500\" height=\"625\"  style=\"display: inline-block;\" \/><\/a><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Within the next few months, mobile devices will be introduced with new form factors. First of these form factors that will be offered in the market are fol&#8230;..<\/p>\n","protected":false},"author":7,"featured_media":6751,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1915],"tags":[64,71,1144,6,700],"class_list":["post-4603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ndocs","tag-android","tag-android-pie","tag-foldable","tag-programming","tag-samsung"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/posts\/4603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/comments?post=4603"}],"version-history":[{"count":0,"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/posts\/4603\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/media\/6751"}],"wp:attachment":[{"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/media?parent=4603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/categories?post=4603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gtechbooster.com\/api-json\/wp\/v2\/tags?post=4603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}