title: Handling Display Size change
body: <p>I am migrating my app target SDK Version to android oreo.</p>
  
  <p>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.</p>
  
  <blockquote>
    <p>When the device density changes, the system notifies running apps in
    the following ways:</p>
    
    <p>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.</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>I create a Dialog box on the start of the Async Task and hide it when the Async Task has done its work.</p>
  
  <p>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.</p>
  
  <p>My app's orientation locked to portrait.</p>
  
  <p>How should I handle such a scenario? Any help is appreciated. Thanks!</p>
  
  <p>EDIT: This is the scenario</p>
  
  <p>1) App Start</p>
  
  <p>2) Main Screen</p>
  
  <p>3) Users Press A Button</p>
  
  <p>4) AsyncTask inside Main Screen Started</p>
  
  <p>5) A Dialog Box is shown with the progress of task</p>
  
  <p>6) User Minimizes the App and Goes to setting </p>
  
  <p>7) Changes the Display Size/Density or changes the Font Size of the device</p>
  
  <p>8) My App is called by the OS in such a way as if the device rotation is changed </p>
  
  <p>9) Then the user returns back to the app </p>
  
  <p>10) But the dialog box shown is no more being shown </p>
  
  <p>11) But the async Task is running in the background and is still performing its task</p>
  
  <p>12) The task is actually done but the user thinks that the task is still not done.</p>