当前位置: 代码迷 >> 综合 >> 使用Inent 携带 Bundle 携带 数组 传递给另外一个activity
  详细解决方案

使用Inent 携带 Bundle 携带 数组 传递给另外一个activity

热度:22   发布时间:2023-10-30 13:23:36.0

在activity发送数组:

public static String [] PhoneAndTime = new String[2];
//new 新的IntentIntent data = new Intent(MainActivity.this, Demo_1.class);//用Bundle 携带数组Bundle bundle = new Bundle();bundle.putStringArray("phone_data", PhoneAndTime);//将 data Intent 添加Bundledata.putExtras(bundle);startActivity(data);

在另外一个activity中取得数组:

Bundle bundle = this.getIntent().getExtras();
String [] data = bundle.getStringArray("phone_data");

  相关解决方案