我正在构建一个Android应用,可以在自定义信息窗口中查找并显示最近药店的位置及其详细信息。当我运行应用程序时它能够启动但是在点击按钮后会显示最近的药房但应用程序崩溃所以我检查了Logcat并发现了这个错误:
java.lang.IllegalArgumentException:GoogleApiClient未配置为使用此调用所需的LocationServices.API。
我不知道它的这部分代码是否正在创建此错误
Button btnPharma = (Button) findViewById(R.id.btnPharma);
btnPharma.setOnClickListener(new View.OnClickListener(){
String search = "pharmacy";
@Override
public void onClick (View v){
mMap.clear();
String url = getUrl(latitude, longitude, search);
Object[] DataTransfer = new Object[2];
DataTransfer[0] = mMap;
DataTransfer[1] = url;
GetNearbyBanksData getNearbyPlacesData = new GetNearbyBanksData();
getNearbyPlacesData.execute(DataTransfer);
Toast.makeText(pharma2.this, "These are your Nearby Pharmacies! ",
Toast.LENGTH_LONG).show();
}
});
这是执行最近药房显示的班级按钮。
这是Logcat错误行
java.lang.IllegalArgumentException: GoogleApiClient is not configured to use LocationServices.API required for this call.
at com.google.android.gms.common.internal.zzbp.zzb(Unknown Source)
at com.google.android.gms.common.api.internal.zzbd.zze(Unknown Source)
at com.google.android.gms.internal.zzbym.requestLocationUpdates(Unknown Source)
at com.example.sachiewerk.smart_healthcare.pharma2.onConnected(pharma2.java:304)
at com.google.android.gms.common.internal.zzad.zzk(Unknown Source)
at com.google.android.gms.common.api.internal.zzbd.zzj(Unknown Source)
at com.google.android.gms.common.api.internal.zzar.zzahc(Unknown Source)
at com.google.android.gms.common.api.internal.zzar.onConnected(Unknown Source)
at com.google.android.gms.common.api.internal.zzbl.onConnected(Unknown Source)
at com.google.android.gms.common.api.internal.zzw.onConnected(Unknown Source)
at com.google.android.gms.common.internal.zzab.onConnected(Unknown Source)
at com.google.android.gms.common.internal.zzn.zzajo(Unknown Source)
at com.google.android.gms.common.internal.zze.zzs(Unknown Source)
at com.google.android.gms.common.internal.zzi.zzajp(Unknown Source)
at com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
答案 0 :(得分:0)
您需要创建两个不同的GoogleApiClient
个实例:一个用于LocationServices
API,另一个用于Places
API。