c# - 如何在 c# 中的 xamarin android 中识别 android 移动设备 uniqueid

标签 c# security xamarin xamarin.android

对于我的应用程序,我需要跟踪用户的 android 设备 unique id,android 设备将由客户提供给员工,当他们使用该设备时打开我们的应用程序并键入一些代码。我们必须检查请求是否来 self 们员工的设备,然后我们才会打开应用程序。如果其他人的手机中有此应用程序,即使应用程序无法打开。这是客户想要的要求,我在谷歌上搜索了很多,发现链接很少。 试过这个但没有用

  public static String getDeviceAndroidID(Context context)
  {
      String android_id = Secure.getString(context.getContentResolver(),     Secure.ANDROID_ID);
      if(android_id != null)
          return android_id;
      else
          return "";
   }

试过了但没有得到“context.getcontentresolver()” 需要一些帮助,谢谢。

最佳答案

试试 Android.Provider 命名空间:

var android_id = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId);

关于c# - 如何在 c# 中的 xamarin android 中识别 android 移动设备 uniqueid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38631354/

相关文章:

c# - 如何从 foreach 循环中排除特定类型的控件?

flutter - 如何从受 Cloudflare DDOS 保护的 URL 获取 Assets ?

javascript - 如何确保只有我自己的网站(客户端代码)可以与 Firebase 后端对话?

python - Django 远程用户认证和安全

xamarin - 使用 MvxPopRecursivePresentationHint(levelsDeep : 2) no longer renders View when upgrading MvvmCross from 6. 3.1 到 7.1.2

c# - C#、评估和自定义编译器中方法的纯度?

c# - 使用 List.Sort(Comparison<T> comparison) 在 C# 中对列表进行排序

c# - 如何在不使用 Subjects 或 .NET 事件的情况下创建在方法调用时发出的 IObservable?

ios - 使用 Xamarin 的文件应用程序在 iOS 上共享文件

c# - 如何在 Xamarin.Forms.Map 中获取当前位置或移动到当前位置