0

我正在使用 dot42 开发 android 应用程序,但在点击 DownloadString 行时它一直出错

using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using Android.App;
using Android.Os;
using Android.Widget;
using Dot42;
using Dot42.Manifest;

[assembly: Application("innosia.com")]
**[assembly: UsesPermission(Android.Manifest.Permission.INTERNET)]**
[assembly: Dot42.FreeAppsKey("##censored##")]
namespace innosia.com
{
    [Activity]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            SetContentView(R.Layouts.MainLayout);

            var textView = FindViewById<TextView>(R.Ids.MyText);

            List<string> titles = GetTitles();

            textView.SetText(string.Join(",", titles));
        }

        public List<string> GetTitles()
        {
            var webClient = new WebClient();
            **var data = webClient.DownloadString("http://www.sorainnosia.com/animea");**
            string[] temps = data.TagMatch("<td><a href=\"javascript:Submit(", "</a>");
            List<string> result = new List<string>();
            foreach (string str in temps)
            {
                string t = str.Substring(str.IndexOf("\">") + 2);
                result.Add(t);
            }
            return result;
        }
    }
}

粗线会导致错误但VS无法显示错误详细信息,我已经添加了UsePermission Internet但它仍然给出错误,有人知道为什么吗?

4

1 回答 1

0

我没有尝试过,但您可能还需要权限 ACCESS_NETWORK_STATE。

于 2013-10-05T08:07:18.977 回答