简体   繁体   English

Monodroid-ImageView-> SetImageURI崩溃应用程序

[英]Monodroid - ImageView -> SetImageURI crash application

I have an issue displaying a picture taken from the Camera. 显示从相机拍摄的照片时出现问题。 I proceed as the following: 我按以下步骤进行:

  1. Calling Camera Activity -> Saving Picture -> Keeping Picture Location as a string. 调用摄像机活动->保存图片->将图片位置保留为字符串。
  2. Creating a new Intent -> Setting String extra with the Picture Location. 创建一个新的Intent->在图片位置额外设置字符串。
  3. Calling the activity and retreiving the string. 调用活动并获取字符串。
  4. Switching back to an URI using Parse on the string containing the file location. 在包含文件位置的字符串上使用Parse切换回URI。
  5. Calling SetImageURI on the ImageView. 在ImageView上调用SetImageURI。 <- this crashes. <-这崩溃。

I get the "Application had to close unexpectedly" thing.. 我得到“应用程序不得不意外关闭”的东西。

Not really handy to debug. 调试起来并不方便。

There's the code for the Activity: 有该活动的代码:

    [Activity (Label = "ViewPhoto")]            
public class ViewPhoto : Activity
{
    ImageView image;
    protected override void OnResume ()
    {
        string PhotoLocation = Intent.GetStringExtra ("PicLoc");
        Android.Net.Uri _img = Android.Net.Uri.Parse (PhotoLocation);
        image.SetImageURI (_img);
    }

    protected override void OnCreate (Bundle bundle)
    {
        base.OnCreate (bundle);
        SetContentView(Resource.Layout.PhotoViewer);
        image = FindViewById<ImageView> (Resource.Id.exCurrentPhoto);
    }
}

I checked the picture weight.. it's 9kb (its probably a simple picture generated through the android emulator I use).. so I doubt it's a memory issue oo 我检查了图片的权重..它是9kb(可能是通过我使用的android模拟器生成的简单图片)..所以我怀疑这是内存问题oo

Thanks for helping. 感谢您的帮助。

I hate myself for not noticing I had forgotten to call the base.OnResume() function... Without exception being thrown I didn't realise until I randomly had to go through the Android LogCat x) 我讨厌自己没有注意到我忘记了调用base.OnResume()函数...无一例外地抛出,直到我随机不得不通过Android LogCat x时我才意识到

Problem solved =D 解决的问题= D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM