Sunday, 23 December 2018

Handling Display Size change

I am migrating my app target SDK Version to android oreo.

One of the changes which might affect the app is that if the Display size of the device is changed then the app targeting Android Nougat and above will be notified as if there is a change in orientation of the device. Below is the source.

When the device density changes, the system notifies running apps in the following ways:

If an app targets API level 23 or lower, the system automatically kills all its background processes. This means that if a user switches away from such an app to open the Settings screen and changes the Display size setting, the system kills the app in the same manner that it would in a low-memory situation. If the app has any foreground processes, the system notifies those processes of the configuration change as described in Handling Runtime Changes, just as if the device's orientation had changed. If an app targets Android 7.0, all of its processes (foreground and background) are notified of the configuration change as described in Handling Runtime Changes.

Now my app has a longrunning process which runs in an Async TSak in an Android Activity. Which means that the App has an AsyncTask which is inside the Activity Code.

I create a Dialog box on the start of the Async Task and hide it when the Async Task has done its work.

Now suppose the users start the task and then goes to the setting and changes the Display Size then return back to my app then the dialog box of the app is gone by the Async Task is still performed till the end which mean that the user might think that the app has finished the task but whereas the app would be actually performing the task. But my Activity is also responding as if restarted except that Async Task is running.

My app's orientation locked to portrait.

How should I handle such a scenario? Any help is appreciated. Thanks!



from Handling Display Size change

No comments:

Post a Comment