如何在Xamarin Android中将图像从一个活动传递到另一个活动?

时间:2016-07-27 03:13:58

标签: c# android mobile xamarin apk

我在Xamarin Android项目中的图像活动中有一个ImageView。我需要通过单击按钮将该图像传递给另一个活动。

Intent intent = new Intent(this, typeof(SecondActivity));
intent.PutExtra("Key", "Value");

我知道上面传递字符串等的方法但是如何传递图像?

1 个答案:

答案 0 :(得分:1)

在活动之间传递数据

https://developer.xamarin.com/recipes/android/fundamentals/activity/pass_data_between_activity/

你会想要这样的例子:

Intent intent = new Intent (MediaStore.ActionImageCapture);
App._file = new File (App._dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid()));
intent.PutExtra (MediaStore.ExtraOutput, Uri.FromFile (App._file));
StartActivityForResult (intent, 0);

来源:

https://developer.xamarin.com/recipes/android/other_ux/camera_intent/take_a_picture_and_save_using_camera_app/