【问题标题】:How to access to the ServiceManager with Xamarin Android如何使用 Xamarin Android 访问 ServiceManager
【发布时间】:2016-04-12 06:15:48
【问题描述】:

我正在使用 Xamarin.Android 开发一个 Android 应用程序。我必须访问 ServiceManager 才能检索特定的 IBinder。 Java 应用程序可以访问和看到 ServiceManager,但我在 Visual Studio 项目中看不到它,并使用了引用的 Mono.Android dll。

相对Java代码:

IBinder b = ServiceManager.getService("<service-name>");

如何使用 Xamarin.Android 库在 C# 上获得相同的行为?

【问题讨论】:

  • 这是一个标有@hide 注释的类,因此您也无法在Java 中访问。请尝试使用其他公共 API。

标签: c# android mono xamarin.android monodevelop


【解决方案1】:

在你的活动中试试这个:var a = Application.GetSystemService ("name-service");

祝你好运

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多