2012-03-29 9 views
3

た後、私は次のコードを持っている:startActivity(意図)が呼び出された後)(onResumeの古い意図エキストラを取得startActivity(newIntent)呼び出しアクティビティで

Intent intent = new Intent(); 
intent.setClass(CallingActivity.this, CalledActivity.class); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
intent.putExtra(key, new_value); 
startActivity(intent); 

、制御はonResume(に行く)をCalledActivityの

しかし、CalledActivityのonResume()では、getIntent()はCallingActivityによって設定された新しいインテントではなく、古いインテントを返します。

CalledActivityのonResume()で新しいインテントを取得するにはどうすればよいですか?

+1

「シングルタスク」または「シングルトップ」としてアクティビティをマークしましたか? – dreamtale

+0

あなたは私の答えを見ましたか? – dreamtale

答えて

9

アクティビティのonNewIntent (Intent intent)メソッドをオーバーライドし、setIntent(Intent)を使用してインテントを更新する必要があります。

+0

私の魅力のように働いた。ありがとう! +1 –

+0

完璧に機能しました。 +1 –

1

dreamtaleの回答を拡大するには、あなたのアクティビティに次のメソッドを追加してください。

@Override 
public void onNewIntent (Intent intent) { 
    setIntent(intent); 
    super.onNewIntent(intent); 
} 
関連する問題