Start Activity For Result Not Working
I'm using start Activity result for starting a new activity to select a image from gallery and it will return a image path to my main activity to , so that it will insert image in
Solution 1:
The intent is wrong, try this:
Intentintent=newIntent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
Solution 2:
Start Activity
privatestaticfinalintPICK_IMAGE=1;
Intentintent=newIntent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
Take Result
@OverrideprotectedvoidonActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == PICK_IMAGE && data != null && data.getData() != null)
{
Uri_uri= data.getData();
//User had pick an image.Cursorcursor= getContentResolver().query(_uri, newString[] {
android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null);
cursor.moveToFirst();
//Link to the imagefinalStringimageFilePath= cursor.getString(0);
cursor.close();
}
super.onActivityResult(requestCode, resultCode, data);
}
Post a Comment for "Start Activity For Result Not Working"