【问题标题】:Getting Location in Android在 Android 中获取位置
【发布时间】:2015-01-20 17:43:49
【问题描述】:

我正在 Android 示例表盘上进行编码。我想连接到 Google Play 服务以获取我当前的位置,并将其放入我的 OnCreate 方法中:

mGoogleApiClient = new GoogleApiClient.Builder(this)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .addApi(LocationServices.API)
    .build();

像这样:

我的错误如下:

第一个 this 不能应用于引擎。 mGoogleApiClient,LocationServices 无法解析为符号。我已经尝试实现/扩展我的 Engine 类,但这是不允许的。问题可能出在我放入此代码的类,因为它的组织方式可能不同?我怎样才能使这项工作?谢谢。

【问题讨论】:

    标签: android google-play-services wear-os android-location android-context


    【解决方案1】:

    你有最新的 google api 更新吗?您是使用 Android Studio 还是 Eclipse 进行开发?您确定您的导入正确且 Google Play 服务在您项目的同一工作区中吗?我有一个类似的问题,并在 eclipse 中使用 ADT 更新修复它。

    【讨论】:

    • 我在 Android Studio 上,我认为 Google Play 已导入,因为它在我的清单和项目结构中。 6.5.+ 在那里。问题可能出在我放入此代码的类,因为它的组织方式可能不同?这是在 AnalogWatchFaceService 内部。
    猜你喜欢
    • 1970-01-01
    • 2013-09-08
    • 1970-01-01
    • 1970-01-01
    • 2011-07-15
    • 2016-12-01
    • 2018-02-08
    • 1970-01-01
    • 2021-12-13
    相关资源
    最近更新 更多