PDA

View Full Version : Intent آرایه دوبعدی



kamal70
جمعه 13 مرداد 1396, 10:51 صبح
سلام می خوام با intent یک آرایه دوبعدی انتقال بدم
اون طرف که دریافت می کنم با کد
Getintent().GetIntarrayextra ()
دریافت می کنم
الان می خوام اینو بریزم داخل آرایه دوبعدی قبول نمی کنه می نویسه باید آرایه یک بعدی تعریف بشه.
با این کد آرایه دو بعدی دریافت می کنند؟

h3lper
شنبه 14 مرداد 1396, 10:35 صبح
String[][] arrayToSend=new String[3][30];
String stringToSend="Hello";
Intent i = new Intent(this, NewActivity.class);


i.putExtra("key_string",stringToSend);


Bundle mBundle = new Bundle();
mBundle.putSerializable("key_array_array", arrayToSend);
i.putExtras(mBundle);


startActivity(i);






String sReceived=getIntent().getExtras().getString("key_string");


String[][] arrayReceived=null;
Object[] objectArray = (Object[]) getIntent().getExtras().getSerializable("key_array_array");
if(objectArray!=null){
arrayReceived = new String[objectArray.length][];
for(int i=0;i<objectArray.length;i++){
arrayReceived[i]=(String[]) objectArray[i];
}
}