【问题标题】:Uri.Parse deprecated不推荐使用 Uri.Parse
【发布时间】:2017-01-12 13:53:36
【问题描述】:

我有一个条形码扫描仪应用程序。我正在尝试扫描条形码并在谷歌搜索。但是当我尝试按照提到的here 进行搜索时,它会显示Uri.Parse() 已弃用。我找不到任何有用的东西,Uri 文档没有说明任何内容。

Uri 文档

https://developer.android.com/reference/android/net/Uri.html

还有其他选择或替代吗?

【问题讨论】:

  • 为什么我在这里投了反对票?我很困惑。
  • 我的 android studio 没有这么说(因为你注意到文档也没有说一句话),所以你可以忘记它(并责怪 Visual Studio)

标签: c# android xamarin xamarin.android uri


【解决方案1】:

您从System 引用Uri,其中ParseObsolete

[ObsoleteAttribute("The method has been deprecated. It is not used by the system.
protected virtual void Parse()

您引用的 SO 问题是使用 Android.Net 命名空间中的 Uri

Android.Net.Uri uri = Android.Net.Uri.Parse("http://www.google.com/#q=fish");
var intent = new Intent(Intent.ActionView, uri);
StartActivity(intent);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-22
    • 2012-11-14
    • 2019-11-08
    • 2019-11-08
    • 2020-01-03
    • 2011-12-02
    • 2015-01-24
    相关资源
    最近更新 更多