How to show splash screen when app is in background in Android? -


i have splash screen(couldn't avoid it, branding reasons) application.

i want mask user interface , show splash screen when in background (like banking applications do).

should overide onpause() , onresume() view in mainactivity?

manifest:

<application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:supportsrtl="true"     android:theme="@style/apptheme">     <activity android:name=".splashactivity">         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity         android:name=".mainactivity"         android:label="@string/title_activity_main"         android:theme="@style/apptheme.noactionbar"></activity> </application> 

splash activity : oncreate()

setcontentview(r.layout.splash_layout); new handler().postdelayed(new runnable() {         @override         public void run() {             /* create intent start main-activity. */              intent intent = new intent(this, mainactivity.class);             startactivity(intent);             finish();         }     }, splash_display_length); } 

mainactivity(): just show layout text , buttons

oncreate():

setcontentview(r.layout.example_view); 

now when application in background , when press menu button see list of applications in stack, should see splashview(the xml file) not deafult behaviour i.e mainactivity layout.

one of things tried out adding

getwindow().setflags(windowmanager.layoutparams.flag_secure,                 windowmanager.layoutparams.flag_secure);  

which mask application when in background white screen i'm trying show splash view when app in background.

i know ios banking application has feature.

edited : enter image description here

if see twitter app(example) in background, want mask application view splash screen. right using flag_secure helps me mask screen white screen want show splash layout rather white screen.

  • if see below picture ios device - discover application (example) masks app splash screen, can done on android?

enter image description here

can done on android?

not directly, afaik.

should overide onpause() , onresume() view in mainactivity?

probably not. while welcome change ui there:

  • those methods called other reasons (e.g., when user taps on window in multi-window mode, when launch of activities)

  • that may late respect when screenshot taken


Comments