I have a Splash screen(Couldn't avoid it, as it is for branding reasons) for my application.
I want to mask the user interface and show the splash screen when it is in background (like banking applications do).
Should I overide onPause() and onResume() for the 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 an Intent that will start the Main-Activity. */
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
MainActivity(): Just show a layout with text and buttons
onCreate():
setContentView(R.layout.example_view);
Now when my application is in background and When I press Menu button to see list of applications in my stack, I should see the splashview(the xml file) not the deafult behaviour i.e MainActivity layout.
One of the things I tried out is adding
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE);
which does mask the application when it is in background with White Screen but I'm trying to show the splash view when the app is in background.
I know all the iOS Banking application has this feature.
Edited :
If you see the twitter app(Example) in the background, I want to mask the application view with splash screen. Right now using FLAG_SECURE helps me to mask the screen with white screen but I want to show Splash layout rather than white screen.
Can this be done on Android?
Not directly, AFAIK.
Should I overide onPause() and onResume() for the view in MainActivity?
Probably not. While you are welcome to change your UI there:
Those methods get called for other reasons (e.g., when the user taps on another window in multi-window mode, when you launch another of your activities)
That may be too late with respect to when the screenshot is taken
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With