android.os.BinderProxy cannot be cast to com.android.server.am.Activit 解决办法

来源:互联网 发布:加强网络管理的通知 编辑:程序博客网 时间:2024/05/16 08:43

安卓开发在使用百度地图的过程中,试图通过百度地图获取当前经纬度 控制台报错:


Bad activity token: android.os.BinderProxy

java.lang.ClassCastException: android.os.BinderProxy cannot be cast to com.android.server.am.ActivityRecord$Token


原因是调用 LocationClient 初始化的时候 使用了


locationClient = new LocationClient(this);


如果当前 activity 不是 Main 启动的话。


需 把上面代码改成:


locationClient = new LocationClient(getApplicationContext());


即可


0 0