How to pass a String array value from one activity to another Activity in android?

前端 未结 6 1550
北荒
北荒 2020-12-15 14:20

I am having two activities in my application. I want to pass tha array of String from one activity to another.. How to pass this values from activity to activity?

6条回答
  •  情歌与酒
    2020-12-15 14:20

    You can consider using Intent.getStringArrayExtra

    In the first activity:

    Intent intent = new Intent(context, NewActivity.class);
    intent.putExtra("string-array", stringArray);
    context.startActivity(intent);
    

    and in the second one:

    Intent intent = getIntent();
    String [] stringArray = intent.getStringArrayExtra("string-array");
    

提交回复
热议问题