Thursday, 15 January 2015

android - Passing string array from one activity to another -



android - Passing string array from one activity to another -

hi passing string array 1 activity another, getting length of array in next activity right when trying utilize array getting null value code below:

public void onitemclick(adapterview<?> parent, view v, int position, long id) { // todo auto-generated method stub // sending image id fullscreenactivity log.e("jjhj",""+position); bitmap imagebitmap=bmp[position]; log.e("image",""+bmp[position]); bytearrayoutputstream bytearrayoutputstream = new bytearrayoutputstream(); imagebitmap.compress(compressformat.png,100, bytearrayoutputstream); byte[] image = bytearrayoutputstream.tobytearray(); bundle bundle=new bundle(); intent = new intent(getapplicationcontext(), viewfullimage.class); // passing array index // i.putextra("image", image); bundle.putstringarray("imagearray",imagegallaryarray); bundle.putint("imageposition",position);; i.putextras(bundle); startactivity(i); }

next activity :

public void oncreate(bundle savedinstancestate) { // viewpager viewpager = (viewpager) findviewbyid(r.id.view_pager); super.oncreate(savedinstancestate); setcontentview(r.layout.viewgallaryfull); // getimages(); bundle bundle=getintent().getextras(); position=bundle.getint("imageposition"); log.e("position",""+position); //string [] imagegal=new string[500]; string [] imagegal=bundle.getstringarray("imagearray"); int length=imagegal.length; log.e("length",""+length); log.e("hut",""+imagegal[1]); for(int i=0;i<length;i++) { log.e("image",imagegal[i]); map = new hashmap<string, string>(); map.put("image",imagegal[i]); myarrlist.add(map); }

well solution looks pretty simple me. way describe either array handing on next activity or string values within array are null. this not issue of transferring data between activities.

make sure array , values not null, , problem solved.

android arrays bundle

No comments:

Post a Comment