在单个Activity上处理多个Intent

时间:2016-11-03 11:51:39

标签: android android-intent bundle

我有三项活动。在let SB: UIStoryboard = UIStoryboard(name: StoryboardName, bundle: Bundle.main) let VC = SB.instantiateViewController(withIdentifier: StoryboardIdOfViewController) if let _ = VC.view { //Do here } 一个(导航菜单)上,我有一个简单的Activity来启动ClickListener两个。

Activity

Intent intent3 = new Intent(this, SettingsActivity.class); intent3.putExtra("from", "BaseActivity"); startActivity(intent3); finish(); break; 三我在Actvity两个上有一些我需要的数据。所以我将数据放在Activity中,如下所示:

Bundle

因此,如果我开始//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,而不会从第三个获得Activity

//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两个调试器,然后从Bundle One获取Activity。如何从Bundle三个获得Activity

1 个答案:

答案 0 :(得分:0)

使用int leftSideOfDecimalPoint = (int) initialFloatValue; // The cast from float to int keeps only the integer part int temp = (int) initialFloatValue * 10; int rightSideOfDecimalPoint = temp % 10; startActivityForResult (Intent intent, int requestCode)开始SettingsActivity

处理结果StartActivity

StartActivity