PERMISSION_UNFINISHED

来源:互联网 发布:simulink一端口多输入 编辑:程序博客网 时间:2024/05/20 12:47

使用百度地图进行poi查询的时候,会返回PERMISSION_UNFINISHED,具体原因不清楚,但是似乎是一个BUG。
我们在返回的result设置定点,调试一下。返回的a,b,c,d为0,e,f,g为null。
这里的a,b,c,,e,f,g分别表示什么。我们可以打开PoiResult的源码,看它是如何定义的。

//// Source code recreated from a .class file by IntelliJ IDEA// (powered by Fernflower decompiler)//package com.baidu.mapapi.search.poi;import android.os.Parcel;import android.os.Parcelable;import android.os.Parcelable.Creator;import com.baidu.mapapi.search.core.CityInfo;import com.baidu.mapapi.search.core.PoiInfo;import com.baidu.mapapi.search.core.SearchResult;import com.baidu.mapapi.search.core.SearchResult.ERRORNO;import com.baidu.mapapi.search.poi.PoiAddrInfo;import com.baidu.mapapi.search.poi.b;import java.util.List;public class PoiResult extends SearchResult implements Parcelable {    private int a = 0;    private int b = 0;    private int c = 0;    private int d = 0;    private List<PoiInfo> e;    private List<CityInfo> f;    private List<PoiAddrInfo> g;    private boolean h = false;    public static final Creator<PoiResult> CREATOR = new b();    PoiResult() {    }    PoiResult(ERRORNO var1) {        super(var1);    }    PoiResult(Parcel var1) {        this.a = var1.readInt();        this.b = var1.readInt();        this.c = var1.readInt();        this.d = var1.readInt();        this.e = var1.readArrayList(PoiInfo.class.getClassLoader());        this.f = var1.readArrayList(CityInfo.class.getClassLoader());    }    public int getCurrentPageNum() {        return this.a;    }    void a(int var1) {        this.a = var1;    }    public int getTotalPageNum() {        return this.b;    }    void b(int var1) {        this.b = var1;    }    public int getCurrentPageCapacity() {        return this.c;    }    void c(int var1) {        this.c = var1;    }    public int getTotalPoiNum() {        return this.d;    }    void d(int var1) {        this.d = var1;    }    public List<PoiInfo> getAllPoi() {        return this.e;    }    void a(List<PoiInfo> var1) {        this.e = var1;    }    public List<PoiAddrInfo> getAllAddr() {        return this.g;    }    void b(List<PoiAddrInfo> var1) {        this.g = var1;    }    public boolean isHasAddrInfo() {        return this.h;    }    void a(boolean var1) {        this.h = var1;    }    public List<CityInfo> getSuggestCityList() {        return this.f;    }    void c(List<CityInfo> var1) {        this.f = var1;    }    public int describeContents() {        return 0;    }    public void writeToParcel(Parcel var1, int var2) {        var1.writeInt(this.a);        var1.writeInt(this.b);        var1.writeInt(this.c);        var1.writeInt(this.d);        var1.writeList(this.e);        var1.writeList(this.f);    }}

在定义中我们可以看到,a表示的是CurrentPageNum,b表示的是TotalPageNum,c表示的是CurrentPageCapacity,d表示的是TotalPoiNum,e表示的是List,f表示的是List,g表示的是List。
再回到那个PERMISSION_UNFINISHED的BUG上来,通过网上查询,发现一个不算办法的办法,就是返回重新打开一次。

这里写图片描述

我重新打开一次发现
这里写图片描述
成功
我们来查看一下返回的数据

这里写图片描述
返回了一个ArrayList,它的size为10,每个item里面包括了一些我们需要的信息:
address(地址),city(城市),location(经纬度),name(名称),phoneNum(联系方式),postCode(邮政编码)。
我调用的是PoiSearch的searchInCity()方法,还有其他的方法searchNearby(),searchInBound(),searchPoiDetail()。

0 0