【问题标题】:How can I pass an Image from one activity to another in Xamarin Android?如何在 Xamarin Android 中将图像从一个活动传递到另一个活动?
【发布时间】:2016-07-27 03:13:57
【问题描述】:

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

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

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

【问题讨论】:

    标签: c# android mobile xamarin apk


    【解决方案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/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-05
      • 1970-01-01
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 2018-03-06
      • 2018-05-31
      相关资源
      最近更新 更多