Tutorial :How pass an image resource from my app to another?



Question:

I have 2 apps running, and I need to pass an image resource from the first app to the second.

The ImageView have a setImageURI(Uri) method, that I could use in the second app, but does not have a getUri() for me to use in the first.

Any idea how to do this?

-- update

looks like Content Providers can solve the problem. (studying)


Solution:1

The only way is to pass the data to the second Activity when you start it. If you check out the Intent API you can pass the Uri using one of the putExtra() methods, and in the onCreate for the new Activity you can retrieve the Uri using getStringExtra().


Solution:2

You can pass a (Bitmap)Drawable this way:

// sending side  BitmapDrawable bd = (BitmapDrawable)imageView.getDrawable();  intent.putExtra("img", bd);    // receiving side  Bitmap b = (Bitmap) intent.getParcelable("img");  imageView.setImageBitmap(b);  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »