Android:Problem in passing image and its URI between two activities

痴心易碎 提交于 2019-12-04 11:29:46

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!