Mono for android - Android.OS和Android.Provider程序集?

时间:2013-03-21 00:58:57

标签: android mono xamarin.android

我正在使用mono for android 4.6,试图获取设备信息。我见过的样品如下,但我不确定要添加什么参考才能获得这些样品?

var device = Android.OS.Build.Device;  //type or namespace OS does not exist...(missing     assembly?)
var id = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId); //type or namespace 'Provider' does not exist..(missing assembly?)

3 个答案:

答案 0 :(得分:1)

尝试这种方式:

using Android.OS;
using Android.Provider;
using Android.Content;
using Android.App;

var device = Build.Device;
var id = Settings.Secure.GetString(Application.Context.ContentResolver, Settings.Secure.AndroidId);

答案 1 :(得分:0)

答案 2 :(得分:0)

这是一个非常古老的问题,但如果有人仍然遇到此问题,只需附加global::,如:

var device = global::Android.OS.Build.Device;  //type or namespace OS does not exist...(missing     assembly?)
var id = global::Android.Provider.Settings.Secure.GetString(ContentResolver, global::Android.Provider.Settings.Secure.AndroidId);