Reputation: 800
i am using tabs at bottom on all screens.,and i am using onactivityresult() method for selecting image from gallery and camera.my code is working without tab activity.,but when i am using my code with tabactivity its not working,i am searching from 2 days ,but no solution is getting.,what i do.., i am so frusted from this,please help me..,thankyou.here is onactivityresult()method:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case 1:
if (resultCode ==RESULT_OK)
{
Uri chosenImageUri = data.getData();
String imagepath= getpath(chosenImageUri);
Bitmap bitmap = BitmapFactory.decodeFile(imagepath);
customImageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 120, 120, false));
Constant._profilePicBase64=Constant.convertBitmapToBase64(bitmap);
getprofilepic();
}else{
Toast.makeText(SettingsActivity.this, "Unable to get Image", Toast.LENGTH_SHORT).show();
}
break;
case 2:
if (resultCode ==RESULT_OK)
{
try{
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
customImageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 120, 120, false));
Constant._profilePicBase64=Constant.convertBitmapToBase64(bitmap);
getprofilepic();
}catch (OutOfMemoryError e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}else{
Toast.makeText(SettingsActivity.this, "Unable to get Image", Toast.LENGTH_SHORT).show();
}
break;
}
}
Upvotes: 1
Views: 651
Reputation: 65
I might be late but anyway this is the answer:
your onActivityResult should be placed in the TabActivity group
and your startActivityForResult should be called referring to the parent Activity
example:
TabActivityGroup parentActivity = (TabActivityGroup) getParent();
Intent gallery = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
parentActivity.startActivityForResult(gallery, IMAGE_PICKER_REQUEST);
Upvotes: 1