title: App freezes/crashes after lockscreen
body: <p>My App has problems when the screen is locked while running. Manually or automatically lock makes no difference. Many of my test-devices don’t come back from lockscreen (e.g. Samsung S4Mini, Samsung S3), others do ( Samsung tab a9). The phones freeze for minutes. Sometimes they never come back out of lockscreen, the devices crash so hard, that only reset or removing the batterie can restart it. I think it has something to do with resuming the app after onDestroy(). The app tries to resume and doesn’t succeed. The resuming after onPause() works fine, by the way.</p>
  
  <p>Who has experience with that issue ?
  Is there a way to force the app to exit completely, when screen is locked, so that it doesn’t try to resume after lockscreen ?</p>
  
  <p>I try to add some logs, but the error is hard to pin down:</p>
  
  <p>on 21.14.367 my app calls onDestroy()
  on 21.16.122 Windowmanager tells something about appfreeze
  on 21.16.487 WM tells Lock Screen displayed!
  on 21.19.317 WM tells Screen frozen for +5s298ms { keyguard}   </p>
  
  <pre><code>12-20 16:21:14.367: W/IInputConnectionWrapper(7025): showStatusIcon on inactive InputConnection
  12-20 16:21:14.367: V/Mw(7025): ECActivity onDestroy() reached
  12-20 16:21:14.367: V/SDL(7025): onDestroy()
  12-20 16:21:14.367: D/KeyguardShortcutView(2347): onDetachedFromWindow()
  12-20 16:21:14.367: D/Tethering(2347): setOemDunRequired
  12-20 16:21:14.367: E/Tethering(2347): No numeric data
  12-20 16:21:14.367: V/KeyguardViewManager(2347): mConfigChangeReceiver.onReceive : action=android.intent.action.CONFIGURATION_CHANGED mLastOrientation=2 orient=1
  12-20 16:21:14.372: E/videowall-TranscodeReceiver(6786): broadcastMSG : android.intent.action.SCREEN_OFF
  12-20 16:21:14.372: D/LSO(2347): Unregistered Intent: android.intent.action.sec.LSO_CONFIG_CHANGED , android.intent.action.MEDIA_MOUNTED
  12-20 16:21:14.372: D/STATUSBAR-QuickSettingPanel(2628): update() : DB_NUMBER_OF_APPS = 10
  
  
  
  12-20 16:21:16.117: D/SSRMv2:CustomFrequencyManagerService(2347): releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT  frequency : 1400000  uid : 1000  pid : 2347  tag : ROTATION_BOOSTER@21
  12-20 16:21:16.122: W/WindowManager(2347): Window freeze timeout expired.
  12-20 16:21:16.122: W/WindowManager(2347): Force clearing orientation change: Window{42ec2de8 u0 com.onemanshowsoft.sparkler/com.onemanshowsoft.sparkler.sparkler}
  12-20 16:21:16.122: W/WindowManager(2347): Force clearing orientation change: Window{42f0ca10 u0 SurfaceView}
  12-20 16:21:16.412: D/InputReader(2347): Input event: value=1 when=380915081000
  12-20 16:21:16.412: D/KeyguardViewMediator(2347): onWakeKeyWhenKeyguardShowing(26)
  12-20 16:21:16.412: D/KeyguardViewMediator(2347): handleWakeWhenReady(26) : mMaybeShow=false
  12-20 16:21:16.412: D/KeyguardViewManager(2347): wakeWhenReady(26)
  12-20 16:21:16.412: D/KeyguardHostView(2347): onWakeKey
  12-20 16:21:16.412: D/KeyguardHostView(2347): poking wake lock immediately
  
  
  
  12-20 16:21:16.487: I/WindowManager(2347): Lock screen displayed!
  12-20 16:21:16.487: D/PowerManagerNotifier(2347): [api] WindowManagerPolicy.ScreenOnListener : Received onScreenOn().
  
  
  
  12-20 16:21:19.237: D/dalvikvm(2347): GC_CONCURRENT freed 2464K, 10% free 36577K/40228K, paused 5ms+13ms, total 149ms
  12-20 16:21:19.317: W/WindowManager(2347): App freeze timeout expired.
  12-20 16:21:19.317: W/WindowManager(2347): Force clearing freeze: AppWindowToken{43db7af0 token=Token{43b1fed0 ActivityRecord{42ef1680 u0 com.onemanshowsoft.sparkler/.sparkler}}}
  12-20 16:21:19.317: I/WindowManager(2347): Screen frozen for +5s198ms due to Window{42d2f990 u0 Keyguard}
  12-20 16:21:19.322: I/SurfaceFlinger(1933): id=21 createSurf (2560x720),-1 flag=20004, ClackSurfac
  12-20 16:21:19.322: I/SurfaceFlinger(1933): id=22 createSurf (1280x1440),-1 flag=20004, ClackSurfac
  12-20 16:21:19.322: I/SurfaceFlinger(1933): id=23 createSurf (2560x720),-1 flag=20004, ClackSurfac
  12-20 16:21:19.322: I/SurfaceFlinger(1933): id=24 createSurf (1280x1440),-1 flag=20004, ClackSurfac
  12-20 16:21:19.322: D/InputDispatcher(2347): setInputDispatchMode: enabled=1, frozen=0
  12-20 16:21:19.322: D/lights(2347): button : 1 +
  12-20 16:21:19.322: D/lights(2347): button : 1 -
  12-20 16:21:19.322: V/WindowManager(2347): Window{42d2f990 u0 Keyguard}mOrientationRequetedFromKeyguard=true
  12-20 16:21:19.322: D/PowerManagerService(2347): [api] setUserActivityTimeoutOverrideFromWindowManagerInternal: timeoutMillis: 5000
  12-20 16:21:19.322: D/PowerManagerService(2347): [s] getScreenOffTimeoutLocked: 600000 -&gt; 5000
  </code></pre>