C# 如何在UI层访问GetSystemService(AudioService)
我正在Xamarin开发android应用程序。我想在UI层中创建一个接口及其实现类。正如您在下面的代码中看到的, 当我使用C# 如何在UI层访问GetSystemService(AudioService),c#,android,xamarin,mvvmcross,C#,Android,Xamarin,Mvvmcross,我正在Xamarin开发android应用程序。我想在UI层中创建一个接口及其实现类。正如您在下面的代码中看到的, 当我使用 this.GetSystemService(AudioService); 它从未被承认。 请看下面的进口商品。请让我知道如何让它工作 代码: public class ImplClass : InterfaceFile { public bool IsAllowed(Context ctx) { AudioManager au
this.GetSystemService(AudioService);
它从未被承认。
请看下面的进口商品。请让我知道如何让它工作
代码:
public class ImplClass :
InterfaceFile
{
public bool IsAllowed(Context ctx)
{
AudioManager audioMgr =
(AudioManager)this.GetSystemService(AudioService);
}
}
using System;
using System.Runtime.Remoting.Contexts;
using Android.Media;
using MvvmCross.Platform;
using Android.Content.PM;
导入:
public class ImplClass :
InterfaceFile
{
public bool IsAllowed(Context ctx)
{
AudioManager audioMgr =
(AudioManager)this.GetSystemService(AudioService);
}
}
using System;
using System.Runtime.Remoting.Contexts;
using Android.Media;
using MvvmCross.Platform;
using Android.Content.PM;
您可以使用“应用程序上下文”
例子:
我正在使用这个,它是有效的
global::Android.App.Application.Context.GetSystemService