如何解决“启动屏幕冻结Android应用程序”活动?

时间:2019-07-24 06:08:55

标签: android

从git拉出后,我的应用程序在启动屏幕活动时冻结。这导致了一些冲突,我消除了冲突。之后,我的应用程序在启动屏幕上冻结。即使应用程序没有崩溃,logcat上也没有显示任何错误。怎么解决呢?我在下面共享我的“启动画面”类的代码,

public class SplashScreen extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    /* New Handler to start the Main Activity
     * and close this Splash-Screen after some seconds.*/
    int SPLASH_DISPLAY_LENGTH = 2000;
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(getApplicationContext(), MainActivity.class));
            finish();

        }
    }, SPLASH_DISPLAY_LENGTH);
  }
}

我在下面提供了MainActivity类代码

public class MainActivity extends AppCompatActivity {

private Button bt_SignIn, bt_SignUp;
SharedPref sharedPref;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final InternetConnectionChecker internetConnectionChecker = new InternetConnectionChecker(getApplicationContext());

    bt_SignUp = findViewById(R.id.bt_signUp);
    bt_SignIn = findViewById(R.id.bt_signIn);

    sharedPref = new SharedPref(getApplicationContext());

    if (sharedPref.getLogInData()) {
        startActivity(new Intent(getApplicationContext(), HomeActivity.class));
      }
    }

    bt_SignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (internetConnectionChecker.isConnected()) {
                startActivity(new Intent(getApplicationContext(), OtpSenderActivity.class));
            } else {
                Toast.makeText(getApplicationContext(), "Internet connection is not available.", Toast.LENGTH_SHORT).show();
            }
        }
    });

    bt_SignIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (internetConnectionChecker.isConnected()) {
                startActivity(new Intent(getApplicationContext(), SignInActivity.class));
            } else {
                Toast.makeText(getApplicationContext(), "Internet connection is not available.", Toast.LENGTH_SHORT).show();
            }
        }
    });
  }
}

我正在附加我的logcat状态,此状态正在运行。我刚刚捕获了日志页面。

enter image description here

2 个答案:

答案 0 :(得分:0)

很难看到日志,如果您尝试在没有处理程序的情况下启动活动,则很难

答案 1 :(得分:0)

public class SplashScreen extends AppCompatActivity {

 private int SPLASH_DISPLAY_LENGTH = 2000;

 @Override
  protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 Window window = getWindow();
 window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);

 setContentView(R.layout.activity_splash_screen);







new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
        startActivity(new Intent(getApplicationContext(), MainActivity.class));
        finish();
       }
    }, SPLASH_DISPLAY_LENGTH);
 }
}

也请检查清单是否定义了MainActivity

如果仍然不起作用,请删除为窗口设置的标志,而是添加

android:theme="@style/AppTheme.NoActionBar"

在飞溅活动下的清单中进行全屏观察