6

1つのアクティビティから別のアクティビティに移動すると、2秒間白い画面が表示されます。私はこのコードを使用しています:アクティビティの切り替え中に白い画面が表示される

Intent intent = new Intent(this, SecondActivity.class); 
startActivity(intent); 

どうすればこの問題を解決できますか?

Intent intent = new Intent(this, SecondActivity.class); 
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 
+1

上記マニフェストセットで

<style name="YourTheme" parent="YourParentTheme"> <item name="android:windowBackground">@android:color/transparent</item> </style> 

はあなたの第2の活性XMLとJavaファイルを示しています。 –

+0

こんにちはDivya! ! – Piyush

+0

SecondActivityにWebサービスがありますか? – Amsheer

答えて

0

てみアクティビティをクリアしたい場合はとき意味あなたは背を押すと、何も積み重ねられません。

だから、finishを使用しない場合は、使用しないでください。

0

を呼び出す前にintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);を追加

+0

finish()の目的は何ですか? –

+0

to finish()現在のアクティビティ –

+0

現在の(最初の)アクティビティを終了したくありません。 – androidXXX

0

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

0

使用finishを追加しようと次のアクティビティの使用フラグに移動するにはstartActivity(intent);

Intent intent = new Intent(this, SecondActivity.class); 
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 
1

アクティビティに複雑なレイアウトが含まれている場合、または大きなサイズの背景イメージが含まれている場合はレンダリングが行われるため、そのホワイトページのみが表示されます。その時間遅延を除去したい場合は、低サイズのPNGイメージを使用し、レイアウトデザインをクリアします。

2

アクティビティに複雑なレイアウトが含まれている場合は、フラグを設定してからfinish()を使用しないでください。代わりにFLAG_ACTIVITY_CLEAR_TOP and _TASKを使用し、それはあなたのproblem.Thisが完全

Intent intent = new Intent(this, SecondActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.l̥FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);

または、FLAG_ACTIVITY_NEW_TASKあなたが白い画面を取得しているを使用することにより、単にIntent intent = new Intent(this, SecondActivity.class); startActivity(intent);

以下

+0

残念ながら、あなたの現在の活動は終了しません。 – Galya

1

ように使用削除私のために働いた解決しますこれはこれを使用するように。それが動作します。

Intent intent = new Intent(this, SecondActivity.class); 
startActivity(intent); 
7

このようなテーマを作成します。ActivityTwoにActivityOneから切り替えながらActivityTwoのonCreateメソッドが実行されますまで、あなたの第二の活動

+1

これは私のために働いた:) – Burf2000

+0

あまりにも私のために働いた。ありがとうございました。 – Ilber

+0

これは実際に何をしていますか? –

1

にこのテーマを適用するデフォルトの背景があるが示されている

<style name="YourTheme" parent="YourParentTheme"> 
    <item name="android:windowDisablePreview">true</item> 
</style> 

を白黒画面。良い方法は、onCreateで大量の操作をしないことです。問題を解決するには、以下のように透明な背景をActivityTwoに設定します。テーマ

<activity 
      android:name=".ActivityTwo" 
      android:theme="@style/YourTheme"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
</activity> 
関連する問題