あるアクティビティから複数のアクティビティを特定の順序で呼び出す方法を説明できますか?Android:特定の順序で複数のアクティビティを連続して呼び出す
実際には、最初のサブアクティビティ(該当する条件が真である場合)を呼び出し、終了するのを待ってから2番目のサブアクティビティを呼び出します(条件付きでも可能です)。に。最後に、アプリは別のアクティビティに移動し、サブアクティビティが呼び出されたアクティビティを閉じる必要があります。
問題は、アプリケーションが一度にすべてのインテントを実行し、最後に呼び出されるはずのアクティビティが最初に画面に表示されることです。ここで
はコードです:私が欲しいもの
@Override
public void onResume()
{
super.onResume();
if(allocated)
{
super.onResume();
if (warEvent)
{
Intent intent = new Intent(this, War.class);
warEvent = false;
startActivity(intent);
}
if (annexEvent)
{
Intent intent = new Intent(this, Annexation.class);
annexEvent = false;
startActivity(intent);
}
if (heirEvent)
{
Intent intent = new Intent(this, Dynasty.class);
heirEvent = false;
startActivity(intent);
}
if (diseaseEvent)
{
Intent intent = new Intent(this, Disease.class);
diseaseEvent = false;
startActivity(intent);
}
if (corruptEvent)
{
Intent intent = new Intent(this, Corruption.class);
corruptEvent = false;
startActivity(intent);
}
if (catchEvent)
{
Intent intent = new Intent(this, CatchCorrupt.class);
catchEvent = false;
startActivity(intent);
}
Intent intent = new Intent(this, Coliseum.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
はように、戦争を呼び出すメインの活動に戻り、その後、併合を呼び出し、およびすることであり、コロシアムは最後に呼び出されなければなりません。何らかの理由で、メインアクティビティのonPause()が呼び出されず、すべてのインテントが一度に実行されるため、Warの代わりにColiseumが最初に呼び出されます。あなたのシナリオの
[Fragments](https://developer.android.com/guide/components/fragments.html)を使ってみませんか? –
'startActivityForResult'を使い、if-elseを実行すると、一度に1つのアクティビティだけを開始できますか? – nasch