4

Can we pass image and an image URI to other activity in same application using bundle?suggest me some way to do that?

USAGE :actually i have made an activity that crop an image taken from camera or from image stored in SD card depends upon the user. and another app that uses a background image and a border image both are overlay so as to see PHOTOFRAME.

So now I want to combine both app so that the cropped image come from first app should become the background image for the second app.ie comes in photoframe.How can i do that?

Geetanjali
  • 1,043
  • 2
  • 13
  • 37
  • 2
    why do you want to pass an image.. why don't you put it in res directory which android provides... – ngesh Aug 03 '11 at 05:14
  • Anyway don't pass an image through intent extras. http://stackoverflow.com/questions/6451202/android-certain-intent-extras-prevent-activity-finish – Maxim Aug 03 '11 at 05:20
  • 1
    You can check this out: http://stackoverflow.com/questions/4352172/how-do-you-pass-images-bitmaps-between-android-activities-using-bundles http://stackoverflow.com/questions/6646979/how-to-pass-image-data-from-one-activity-to-another-activity – Hanry Aug 03 '11 at 05:20
  • I have passed the Uri of the Image – Geetanjali Aug 03 '11 at 07:48

2 Answers2

4

Once you save your image in SD card

use this to cal the other activity.

final Intent intent = new Intent(MyClass.this, TargetClass.class);
final String root = Environment.getExternalStorageDirectory().getAbsolutePath();
intent.setData(Uri.parse(root + "/my/image/path/image.png"));
startActivity(intent);

if you are the reciever then you can get the path by calling

Uri path = getIntent().getData();

in the onCreate of the recieving activity. this is the standard way of checking for path by other activities.

Samuel
  • 9,405
  • 5
  • 41
  • 56
1

Yes you can pass URI object,see putParcelable method in http://developer.android.com/reference/android/os/Bundle.html, URI already implements Parcelable interface,you can use corresponding get methods to get it.If any object that implements Parcelable interface then we can pass it using Bundle.

sunriser
  • 750
  • 3
  • 12