Reputation: 938
when I launch my application, there is a black screen that appears for few moments and then only splash screen appears.I followed some of the solutions from this thread but none worked.What might be the actual cause of it? can anyone help? I have pasted the code below.
SplashScreenActivity.java
public class SplashScreenActivity extends Activity {
private static final int SPLASH_TIME_OUT = 3 * 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
Util.doGuestLoginAndCheckForExpireDate();
UserDetail.deleteUserDetailJson();
Util.setProfileFetchStatus(false);
// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.logoImageViw);
final TranslateAnimation anim = new TranslateAnimation(0f, 0f, 1200f, 0f);
anim.setDuration(1200);
anim.setFillAfter(true);
splash.startAnimation(anim);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
splash.setAnimation(anim);
if (Util.getLoginStatus()) {
startActivity(new Intent(SplashScreenActivity.this, RestActivity.class));
} else
startActivity(new Intent(SplashScreenActivity.this, AppIntroduction.class));
finish();
}
}, SPLASH_TIME_OUT);
}
}
This is thetheme
I've included in Application tag
inside Android manifest.xml
file
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primary_color</item>
<item name="windowNoTitle">true</item>
<item name="colorAccent">@color/primary_color</item>
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:windowContentOverlay">@null</item>
</style>
Anything Am I doing wrong here??
Upvotes: 0
Views: 1312
Reputation: 1298
I had this issue when I updated gradle, I changed it back to prebeta release to fix it. From:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
}
To:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
Upvotes: 1
Reputation: 462
You´ll see black or white depending on chosen theme till the main activity is created, to reduce the time don´t do anything intense in onCreate just set the layout you can move your code to onStart() or onResume() in the linked thread you also see that he set´s android:windowBackground to set the initial background of the activity while loading, can be static image or color
Upvotes: 1