title: How to add FLAG_SECURE on Android 10 - Flutter
body: <p>I have a Flutter project and I need to add a FLAG_SECURE on Android.</p>
  
  <p>Currently, this is the code on my main activity:</p>
  
  <pre><code>import android.os.Bundle
  import io.flutter.app.FlutterActivity
  import io.flutter.plugins.GeneratedPluginRegistrant
  import android.view.WindowManager.LayoutParams;
  
  class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      GeneratedPluginRegistrant.registerWith(this)
    }
  
    public override fun onPause() {
        super.onPause()
        getWindow().addFlags(LayoutParams.FLAG_SECURE)
    }
  
    public override fun onResume() {
      super.onResume()
      getWindow().clearFlags(LayoutParams.FLAG_SECURE)
    }
  }
  </code></pre>
  
  <p>This is working fine except with Android 10.</p>
  
  <p>Examples:</p>
  
  <p>Android 9:
  <a href="https://i.stack.imgur.com/sAERt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sAERt.jpg" alt="enter image description here"></a></p>
  
  <p>Android 10:
  <a href="https://i.stack.imgur.com/aJ6Qy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aJ6Qy.jpg" alt="enter image description here"></a></p>