2016-11-03 9 views
0

3つのアクティビティがあります。 Activityで(ナビゲーションメニュー)、私は簡単ClickListenerActivity 2を開始する必要があります。1つのアクティビティで複数のインテントを処理する

Intent intent3 = new Intent(this, SettingsActivity.class); 
intent3.putExtra("from", "BaseActivity"); 
startActivity(intent3); 
finish(); 
break; 

Actvityに私は、私はActivity二つに必要ないくつかのデータを持っています。だから私はこのようなBundle内のデータを置く:私はActivityつを起動した場合

//send Data to Setting Activity 
Intent mIntent = new Intent(StartActivity.this, SettingsActivity.class); 
Bundle mBundle = new Bundle(); 
mBundle.putString("from", "SettingsActivity"); 
mBundle.putSerializable("spinnerHashTagItems", (Serializable) spinner_HashTagItem); 
mBundle.putSerializable("spinnerUserItem", (Serializable) spinner_UserItem); 
mBundle.putBoolean("isCheckedHashTag", isCheckedHashTag); 
mBundle.putBoolean("isCheckedHashTagUser", isCheckedHashTagUser); 
mBundle.putBoolean("isCheckedAllFromUser", isCheckedAllFromUser); 
mIntent.putExtras(mBundle); 

をだから私は最初のActivityからではなく、サードからIntentを得る:

//get loadet Settings from StartActivity 
Bundle bundle = getIntent().getExtras(); 
if (bundle != null) { 
    //do nothing 
} 

Bundle bundle1 = getIntent().getExtras(); 
spinner_HashTagItems.clear(); 
spinner_HashTagItems = (List<String>) bundle1.getSerializable("spinner_HashTagItem"); 
spinner_userItems.clear(); 
spinner_userItems = (List<String>) bundle1.getSerializable("spinner_userItem"); 
chbox_hashTag.setChecked(bundle1.getBoolean("chbox_hashTag")); 
chbox_hashTagUser.setChecked(bundle1.getBoolean("chbox_hashTagUser")); 
chbox_allFromUser.setChecked(bundle1.getBoolean("chbox_allFromUser")); 

私が一緒に行きましたデバッガはActivityを2つトラップし、BundleActivityから取得します。どうすればBundleActivityから3つ取得できますか?

+0

あるUR' startActivity(mIntent):

StartActivityで結果を処理しますか? –

+0

アクティビティを開始しません。私はデータだけが必要です。アクティビティ1はStartActivityで、開始時に設定をロードし、データをSettingActvity(アクティビティ2)に渡します。私は、Appの開始時に設定を開始したくない。 – dudi

+0

アクティビティ1からアクティビティ2を経由してアクティビティ3に送信したいデータがありますか? – vidulaJ

答えて

0

SettingsActivityStartActivityから開始するには、startActivityForResult (Intent intent, int requestCode)を使用してください。 ; `

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
if (requestCode == REQUEST_CODE_YOU_USED_TO_START_SETTINGS_ACTIVITY) { 
    if (resultCode == RESULT_OK) { 
     //read the data from the Intent and prepare the Bundle for Activity Two 
    } 
} 
} 
関連する問題