Tag: 插件

从Unity3D代码启动android服务

在我的用于android的Unity3D应用程序中,我需要启动一个服务,它将在后台运行。 我无法弄清楚我该怎么做。 必须在活动上调用方法startService() ,但我不知道如何将当前的unity活动从unity脚本传递到我的android插件。 我还没有找到任何方法来获取静态方法中的活动并在其中运行startService() 。 据我了解序列,我需要获得主要的Unity3D活动并从中启动服务。 我的class级应该叫服务。 public final class StatusCheckStarter { public static void StartCheckerService() { startService(new Intent(this, CheckService.class)); } } 这段代码不起作用,因为“无法解析方法startService”而且我没有任何东西要传递给这个参数。 我需要获得当前的活动。