【发布时间】:2015-02-01 04:36:16
【问题描述】:
我在一个片段中有一个MapView,我遇到了两个我似乎无法找到解决方案的问题。我已经搜索过,但我没有看到其他人有这些问题。作为参考,我主要关注开发者页面上的this 教程。
这是我的片段:
public class MapFragment extends Fragment
implements GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener,
LocationListener
第一个问题在这里:
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addApi(LocationServices.API)
.addConnectionCallbacks(this) //problem!
.addOnConnectionFailedListener(this) //problem!
.build();
调用addConnectionCallbacks(this) 会出现错误,指出它不能应用于myPackageName.MapFragment。我知道你必须在这里传递一个GoogleApiClient.ConnectionCallbacks 监听器,但我看到的每个示例都使用this,我不知道该怎么做。 addOnConnectionFailedListener 也出现了同样的问题。在我的片段中,我实现了所有必要的方法,例如onLocationChanged()。
第二个问题在这里:
@Override
public void onConnectionSuspended(int i)
{
Log.i(TAG_MAP_FRAGMENT, "GoogleApiClient connection has been suspended");
}
这会给出一条错误消息:Method does not override method from its superclass。我已经搜索过,但找不到其他有此问题的人。我不确定如何处理它。
有人知道如何解决这些问题吗?感谢您的帮助!
【问题讨论】:
标签: android google-api-client fusedlocationproviderapi