私はアプリの新スタートでのみ表示されているスプラッシュ画面があります。ユーザーがボタンを押してアプリを再起動すると、スプラッシュは表示されません。スプラッシュが表示されない場合、アプリを開くときには1〜2秒の黒い画面が表示されます。ここに私のsplashactivity Javaファイルです。アプリを開くときに黒い画面を削除する方法
public class SplashScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if(!prefs.getBoolean("first_time", false)) // if first time, show splash
{
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("first_time", true);
editor.commit();
setContentView(R.layout.activity_splash);
Thread t = new Thread() {
public void run() {
try {
int time = 0;
while (time < 4000) {
sleep(100);
time += 100;
}
}
catch (InterruptedException e) {
// do nothing
}
finally {
Intent i = new Intent(SplashScreen.this, MainActivity.class);
startActivity(i);
finish();
}
}
};
t.start();
}
else // if not first time, dont show splash
{
setContentView(R.layout.activity_splash);
Intent i = new Intent(SplashScreen.this, MainActivity.class);
startActivity(i);
finish();
}
どうすればこの問題を解決できますか?
この試す:あなたのランチャーの活動では
:あなたのランチャーアクティビティを設定マニフェストに
、 'アンドロイド:テーマ=" @アンドロイド:あなたの 'manifest.xml'の' style/Theme.Translucent''と同じ質問 –
同じ質問をお試しくださいhttps://stackoverflow.com/questions/8817568/how-to-avoid-black-screen-in-android-while-my-app -is-loading –