Skip to content Skip to sidebar Skip to footer

How To Hide Last Activity View In Android Recent List? Using A Locker Screen Implementation

I am using an implementation of locker screen which locks (is displayed on top) the current activity when it is idle for X seconds. However the view for the locker activity is not

Solution 1:

Try FLAG_SECURE:

public class FlagSecureTestActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
                         WindowManager.LayoutParams.FLAG_SECURE);

    setContentView(R.layout.main);
  }
}

It will automatically display a grey background when Recents button is pressed.

A possible side-effect would be that you cant take the screenshot of the activity you are defining this way.

Solution 2:

Try the attribute, android:noHistory="true" for the activity tag in the manifest file.

Solution 3:

The recents app gets something like a "screenshot" when the app goes to background, so before go to background you can fill your activity with a black LinearLayout and onResume check if this LinearLayout is showing and hide. Maybe there are better solutions but this may works.

Post a Comment for "How To Hide Last Activity View In Android Recent List? Using A Locker Screen Implementation"