>我无法迁移我的Android脚本有错误无法解析符号"Geo_data_api" 这是我的完整代码。
package in.techware.lataxi.activity;
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
这有什么问题?
您的操作方式已弃用 您可以从迁移到新地点 SDK 客户端链接查看最新迁移
适用于 Android 的 Places SDK 引入了一个全新的静态库,其中包含更新的功能。适用于 Android 的 Google Play 服务版 Places SDK(即.com.google.android.gms:play-services-places(已于 2019 年 1 月 29 日弃用,并将于 2019 年 7 月 29 日停用。
您必须迁移到新的"地点"SDK。
现在你不需要使用GoogleApiClient类。 代码已弃用,您必须将旧代码迁移到新代码。
我正在发布执行此操作的新方法。
etSearch.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 0) {
recycleView.setVisibility(View.VISIBLE);
imgCancel.setVisibility(View.VISIBLE);
getPlaceAutoCompleteUrl(s.toString());
} else {
recycleView.setVisibility(View.GONE);
imgCancel.setVisibility(View.INVISIBLE);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
public void getPlaceAutoCompleteUrl(String input) {
ApiInterface apiInterface =
RetrofitClient.getClient().create(ApiInterface.class);
StringBuilder urlString = new StringBuilder();
urlString.append("json?input=");
try {
urlString.append(URLEncoder.encode(input, "utf8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
urlString.append("&location=");
urlString.append(mylocation.getLatitude() + "," +
mylocation.getLongitude()); // append lat long of current location to show nearby results.
urlString.append("&radius=500");
urlString.append("&sensor=true");
urlString.append("&language=en");
urlString.append("&key=" + getString(R.string.mapKey));
Log.d("Destination", "apiInter URL " + urlString.toString());
Call<GooglePlaceModal> call = apiInterface.getGooglePlaces(urlString.toString());
call.enqueue(new Callback<GooglePlaceModal>() {
@Override
public void onResponse(Call<GooglePlaceModal> call, Response<GooglePlaceModal> response) {
Log.d("Destination", "apiInter response " + response.body().getPredictions().size());
if (response.body()!=null && response.body().getPredictions()!=null &&response.body().getPredictions().size() > 0) {
recycleView.setVisibility(View.VISIBLE);
list = new ArrayList<>();
list = response.body().getPredictions();
GooglePlaceAdapter(this, list, mWidth);
recycleView.setAdapter(placeAdapter);
placeAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<GooglePlaceModal> call, Throwable t) {
t.printStackTrace();
}
});
}