i have implemented galleryview in one screen named display_image.xml in which i have shown various images available on sdcard now when user selects picture and presses save image button on same screen display_image.xml then selected image should be changed in his/her profile picture in another screen.
My question is that how would i be able to get that image from one screen to change picture of user in another screen and that selected image should also inserted in database for later retrival when user logs in later. Let me tell you that my image dont come from any webservice.
Please help me out……… Thanking You………
First thing you need to do is declare an Intent
and use
startActivityForResult(i_cp, 111);which will be looking for some result. in our case for position of image; an integer value.by specifying request_code (111) that will be used to identify result when returned by started intent. Here we wont use
setAction(i_cp.ACTION_PICK);andsetType("image/*");because we are not going to return image we will just return the position of image. Our use of Intent will be limited to just passing and retrieving the integer value(position of value).Now how about to get that position of image that user has selected. position is got in onItemClick method of GalleryView by one of the parameters
now declare one variable such as int pos; and assign -1 to identify whether the image is selected or not and if the image is selected then in onclick event of button saveimage pass value position as
and in onActivityForResult identify intent by passed requestcode and extract that position as
and set it as
and this array of pics[] which holds all ids of images stored in one of the
res/drawablefolder of your application, declare it asOtherwise you wont able to set the image.