Show splash screen when application enters background android

1.2k Views Asked by At

How can I show android splash screen when the application goes to the back ground?

The issue is that I need to hide my application main page when the user sends the app to the background, and when s/he double tabs the home button, they will see the splash screen.

We were using the following inside our code :

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);


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

It looks like it is fixing the issue, but this code is preventing the user from taking screenshot on the device if the app is in the foreground.

I'm not sure how to implement what i need like I did in iOS.

thanks.

1

There are 1 best solutions below

2
On

Now I haven't personally tried this so I'm not sure if it'll work, but you can try overriding the onPause() method. After overriding onPause() add code that sets your splash screen to cover the entire activity. This should put the image as the app preview in the Recents Panel. Then override the onResume() method to remove the image from the activity, giving the user control again.