1

I start a cam intent and want to retrieve the picture path of the new taken picture in my app. How can I achieve this? I need the path of this picture so that my background service can work with it.

else if (requestCode == TAKE_PICTURE && resultCode == ActionActivity.RESULT_OK){
    Log.i(ACTION_ACTIVITY_TAG, "picture intent gives result ok");
    Bundle b = new Bundle();

    b.putSerializable("picUri", ??????);

    Intent i = new Intent();
    i.putExtras(b);
    i.setClass(this,CommentActivity.class);
}
dandan78
  • 13,328
  • 13
  • 64
  • 78
Al Phaba
  • 6,545
  • 12
  • 51
  • 83

1 Answers1

1

no need to use putSerializable for sending URI of taken image from camera just retrieve uri from intent in onActivityResult and send it as String to another Activity :

else if (requestCode == TAKE_PICTURE && resultCode == ActionActivity.RESULT_OK){
    Log.i(ACTION_ACTIVITY_TAG, "picture intent gives result ok");
    Bundle b = new Bundle();
    Uri picuri = intent.getData();
    b.putString("picUri", picuri.toString());

    Intent i = new Intent();
    i.putExtras(b);
    i.setClass(this,CommentActivity.class);

and in CommentActivity Activity you can retrieve pic URI as :

Intent i = getIntent();
Bundle extras = i.getExtras();

imguri = extras.getString("picUri");
Uri myUri = Uri.parse(imguri);
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213