I'm creating an android application for dual screen that contains 2 activity splash & home where home activity launch mode declared as singleTask as mentioned below:
<activity
android:name=".activity.SplashActivity"
android:theme="@style/FullScreen" />
<activity
android:name=".activity.HomeScreenActivity"
android:launchMode="singleTask"
android:theme="@style/DisableToolbar">
<style name="FullScreen" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:toolbarStyle">@android:color/transparent</item>
</style>
<style name="DisableToolbar" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:toolbarStyle">@android:color/transparent</item>
</style>
The splash screen just plays a 10 sec video & moves to the home activity with some transition animation that works well when we launched it in a single screen but by having a 2 different flavor of the same app & launched it in a both the display at a time the video plays nicely in both screen & when it call the home activity , i can see some android default launcher as a background during transition or before calling home activity,how to get rid of this background. I have tried the following approaches to resolve this issue:
Here is the code snippet for splash activity:
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_activity);
mSurfaceView = findViewById(R.id.splashView);
}
@Override
protected void onStart() {
super.onStart();
setSplashVideo();
}
private void setSplashVideo() {
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
mSurfaceHolder = surfaceHolder;
Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.lr_oval_startup);
if (videoUri != null) {
mMediaPlayer = MediaPlayer.create(SplashActivity.this,
videoUri, mSurfaceHolder);
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mMediaPlayer.start();
}
});
mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
jump();
}
});
}
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
}
});
}
private void jump() {
if (isFinishing())
return;
startActivity(new Intent(SplashActivity.this, HomeScreenActivity.class));
finish();
overridePendingTransition(R.anim.overlay_in,0);
}
@Override
protected void onStop() {
super.onStop();
if (mMediaPlayer != null) {
mMediaPlayer.release();
mMediaPlayer = null;
}
}
Giving theme as FullScreen ie for HomeActivity resolved the issue.