[英]Launch of activity shows white blank windows
当我打开我的应用程序以在设备上进行调试时,它会显示白色空白页约1-2秒,然后显示我的启动屏幕。 我在android开发人员网站上阅读了有关此问题的信息,该问题可能是由于应用程序子类中大量的应用程序初始化导致的。
我的应用程序扩展类代码在这里:
public class MyApplication extends Application{
private static ApplicationComponent mApplicationComponent;
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
if (mApplicationComponent == null){
mApplicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this)).build();
}
}
public static ApplicationComponent providesApplicationComponent(){return Preconditions.checkNotNull(mApplicationComponent);}
}
我的启动画面代码:-
public class SplashActivity extends AppCompatActivity {
@BindView(R.id.splash_screen)
ImageView mSplashScreen;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
Picasso.with(this).load(R.drawable.bg_splash_screen).fit().centerCrop().into(mSplashScreen);
SharedPreferences mSharedPreferences = getSharedPreferences(Constants.PREFERENCE,MODE_PRIVATE);
if (mSharedPreferences.getBoolean(Constants.LOGGEDIN,false)){
Intent homeIntent = new Intent(this, HomeActivity.class);
openPage(homeIntent);
} else {
Intent signupIntent = new Intent(this, SignUpActivity.class);
openPage(signupIntent);
}
}
private void openPage(final Intent intent){
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(intent);
finish();
}
},1200);
}
}
我只在应用程序类中进行这两个初始化。 这是问题吗? 是否可以解决该问题。
当我遇到相同的问题时,经过大量研究,我在styles.xml
添加了以下代码
<item name="android:windowDisablePreview">true</item>
禁用预览会删除即时启动的应用程序,但是由于您具有启动屏幕,因此应该可以使用。
希望它对您也有帮助。
请构建发布模式或禁用即时运行
我想建议禁用即时运行
禁用即时运行:打开设置或首选项对话框。 转到构建,执行,部署>即时运行。 清除“启用即时运行”旁边的复选框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.