c# - Xamarin Forms 从 PCL 请求互联网许可 Android 6

标签 c# android xamarin permissions xamarin.forms

我正在使用 Xamarin.Forms 构建跨平台应用程序。 对于内容,我使用对返回 JSON 的 API 的异步调用。 所以我需要互联网许可。

联系API的代码示例:

var data = await wc.GetStringAsync("http://website.for.content/content-api/Category/?format=json");

这一行在 Android Manifest 中:

  <uses-permission android:name="android.permission.INTERNET" />

我为应用程序编写的所有代码都在一个可移植类库中。所以我(还)没有任何特定于平台的代码。

如何从可移植类库中检查和请求互联网许可?

最佳答案

NormalDangerous权限,Internet访问是正常权限,因此只需要出于安装目的在应用程序的 list 中定义,并在运行时自动授予。

Normal permissions cover areas where your app needs to access data or resources outside the app's sandbox, but where there's very little risk to the user's privacy or the operation of other apps. For example, permission to set the time zone is a normal permission. If an app declares that it needs a normal permission, the system automatically grants the permission to the app

引用:https://developer.android.com/guide/topics/security/normal-permissions.html

关于c# - Xamarin Forms 从 PCL 请求互联网许可 Android 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40088777/

相关文章:

android - 关闭 Activity 后如何刷新以前的 fragment ?

android - 显示键盘时防止 DialogFragment 调整大小/折叠

使用 Parse() 对任何具有 Parse 实现的 T 进行 C# 数据验证

c# - Excel 互操作不接受带逗号的范围

C# 静态 "this"

c# - Entity Framework 代码优先 : CASCADE DELETE for same table many-to-many relationship

java - 安卓通知

android - Xamarin 更新 NuGet 问题

c# - 如何在 Xamarin 中从我的 iOS 应用程序打开 Facebook/Twitter 应用程序?

c# - MvvmCross android 链接器终止绑定(bind)