无法将主Activity转换为位置侦听器,即com.google.android.gms.location.LocationListener

时间:2017-11-25 10:32:41

标签: android google-maps google-maps-api-3 casting locationlistener

因为我完成了我的编码并且厌倦了检查模拟器上的应用程序是什么,并且遇到了一个名为java.lang.ClassCastException的错误,即 UserLocation无法投放到com.google.android.gms.location.LocationListener

我的LOG CAT如下:

所以请各位帮我解决这个问题:D

  

java.lang.ClassCastException:   com.example.surajnath.taproute.UserLocation无法强制转换为   com.google.android.gms.location.LocationListener                                                                                       在   com.example.surajnath.taproute.UserLocation.startLocationUpdate(UserLocation.java:255)                                                                                       在   com.example.surajnath.taproute.UserLocation.onConnected(UserLocation.java:292)                                                                                       在com.google.android.gms.common.internal.zzae.zzk(未知来源)                                                                                       在com.google.android.gms.common.api.internal.zzbd.zzj(未知来源)                                                                                       在com.google.android.gms.common.api.internal.zzar.zzaht(未知   资源)                                                                                       在com.google.android.gms.common.api.internal.zzar.onConnected(未知   资源)                                                                                       在com.google.android.gms.common.api.internal.zzbl.onConnected(未知   资源)                                                                                       在com.google.android.gms.common.api.internal.zzw.onConnected(未知   资源)                                                                                       在com.google.android.gm = s.common.intern   al.zz + ac.onC ++ de here`onn + ected(Unknown Source)                                                                                       在com.google.android.gm = s.common.internal.zzn.zzakg(未知来源)                                                                                       在com.google.android.gm = s.common.internal.zze.zzv(未知来源)                                                                                       在com.google.android.gm = s.common.internal.zzi.zzakh(未知来源)                                                                                       在   com.google.android.g + ms.common.internal.z + Z + h.h +的+ d + 1 + E + M + E + S + S +年龄(未知   资源)                                                                                       在android.o + s.Handler.dispatch + Message(Handler.java:102)                                                                                       在android.o + s.L + ooper.loop(Loo + per.java:154)                                                                                       在android.app.Activity + Thread.main(Activity + Thread.java:6682)                                                                                       at java.la + n + g.reflect.Method.invoke(Native Method)                                                                                       在

现在链接到我的代码如下 https://pastebin.com/3h3CnHWb

1 个答案:

答案 0 :(得分:1)

我认为您在from scipy.stats import pearsonr,spearmanr import numpy as np import pandas as pd df=pd.DataFrame(np.random.randint(0,100,size= (100,10)),columns=list('abcdefghij')) def binary(row): if row>=50: return 1 else: return 0 df['target']=df.a.apply(binary) spearman,spearman_pvalue=spearmanr(df.drop(['target'],axis=1),df.target) print(spearman) print(spearman_pvalue)

中使用了错误的导入 以下

UserLocation

应该是

import android.location.LocationListener;

你需要在gradle依赖项

中使用它
import com.google.android.gms.location.LocationListener;