Xamarin Watch-使用网络服务(Android)

问题描述 投票:0回答:1

我正在尝试从我的android手表调用网站,但是线程退出(线程0x5已退出,代码0(0x0)),但没有结果。我添加了权限“ Internet”和“ Network_state”,但不会更改结果。在我的代码下面(在Tizen和纯Xamarin中完成):

protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.activity_main);

        textView = FindViewById<TextView>(Resource.Id.text);
        Button mybtn = FindViewById<Button>(Resource.Id.btnCal);
        SetAmbientEnabled();

        try
        {
            mybtn.Click += delegate
            {
                Task<string> callTask = calculateRoute();
                callTask.Wait();
                string astr = callTask.Result;
            };
        }
        catch (Exception ex)
        {
            string tt = ex.ToString();
        }
    }

    private async Task<string> calculateRoute()
    {
        HttpClient client;
        try
        {
            String RestUrl = "https://www.google.com";
            var uri = new Uri(string.Format(RestUrl, string.Empty));

            client = new System.Net.Http.HttpClient();

            var response = await client.GetAsync(uri);
            var content = await response.Content.ReadAsStringAsync();

            return content;
        }
        catch (Exception ex)
        {
            string tt = ex.ToString();
            return "";
        }
    }

你有什么想法吗?

谢谢,吉彭

android xamarin tizen-wearable-sdk android-wear-2.0
1个回答
1
投票

经过大量研究后,我找到了解决方案,这要归功于:https://github.com/Samsung/Tizen-CSharp-Samples/tree/master/Wearable

© www.soinside.com 2019 - 2024. All rights reserved.