📜  java intent extras - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:17.391000             🧑  作者: Mango

代码示例1
This is what i have been using, hopfully it helps someone.. simple and affective.

send data

    intent = new Intent(getActivity(), CheckinActivity.class);
    intent.putExtra("mealID", meal.Meald);
    startActivity(intent);
get data

    int mealId;

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();

    if(bundle != null){
        mealId = bundle.getInt("mealID");
    }
cheers!