q9722088
q9722088
2017-12-28 11:04

Android Studio不显示图片

5
  • android-studio

package com.example.q9722.gaicuo;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;

public class SplashActivity extends AppCompatActivity implements Runnable{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide();
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_splash);
    new Thread(this).start();
}

@Override
public void run() {
    SharedPreferences preferences = getSharedPreferences("app_splash",MODE_PRIVATE);
    if(preferences.getBoolean("splash",false)) {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        SharedPreferences.Editor editor = preferences.edit();
        editor.putBoolean("splash",true);
        editor.commit();
    }else {
        Intent intent = new Intent();
        intent.setClass(SplashActivity.this,MainActivity.class);
        startActivity(intent);
        finish();
    }
}

}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答

为你推荐

换一换