【问题标题】:can't access getSystemService无法访问 getSystemService
【发布时间】:2014-07-04 09:23:11
【问题描述】:

我正在尝试调用getSystemServiceActivity 的方法)来访问传感器,但看起来它不存在。

这是我尝试过的代码:

(in-ns 'com....) ; Some Neko project
(.getSystemService a) ; a is :def of Activity

我什至检查了a的所有方法

(use '[clojure.reflect :as r])
(require '[clojure.pprint :only print-table])
(print-table (:members (r/reflect a)))

列表中有getSystemService。 但不知何故我不能称之为:Clojure 说没有这样的方法。

更新: getSystemService 不是静态方法,所以这就是原因,我猜。

但是,有办法吗?

【问题讨论】:

  • 我不是 Android 专家,但似乎Activity.getSystemService() 采用了String 参数,例如(.getSystemService a "window")。至少Activity javadoc 是这么说的。
  • @ez121sl 你是对的,谢谢!您可以发布答案吗?我可以自己做,但我想这不公平。

标签: android clojure clojure-java-interop neko


【解决方案1】:

根据ActivityjavadocActivity.getSystemService() 采用String 参数。没有不带参数的重载方法。消息说没有这样的方法意味着没有该名称的方法不带参数。尝试使用String 参数调用getSystemService,例如:

(.getSystemService a "window")

【讨论】:

    猜你喜欢
    • 2017-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多