I am sending a selected image from image gallery to NextImage.java activity using intent. I want to send the selected position of the image and the arrays of image to next activity. am getting confused with intent.
String[]imageUrls= new String[PostDetails.size()];
for (int index=0;index<imageUrls.length;index++){
imageUrls[index]=PostDetails.get(index).getImag();
}
gallery = (Gallery) findViewById(R.id.img_gallery);
gallery.setAdapter(new ImagePagerAdapter(imageUrls));
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> gallery, View view, int position, long id) {
Intent galleryIntent = new Intent(ImageGalleryActivity.this, MyNextImage.class);
galleryIntent.putExtra(imageUrls, position);
startActivity(galleryIntent);
}
in the next image class:
private ViewPager pager;
String[] imageUrls;
private DisplayImageOptions options;
String images;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_flipper_item);
Bundle bundle = getIntent().getExtras();
String[] imageUrls = bundle.getStringArray(images);
int pagerPosition = bundle.getInt(position, 0);
you put extras as follows:
galleryIntent.putExtra("IMAGE_URLS", imageUrls);
galleryIntent.putExtra("POSITION", position);
and get extras back as follows:
String[] imageUrls = bundle.getStringArray("IMAGE_URLS");
int pagerPosition = bundle.getInt("POSITION", 0);