How to get only City, State, Country from lat, long in android

前端 未结 6 1686
半阙折子戏
半阙折子戏 2021-02-18 19:25

I have the below code to convert lat, long to human readable address. Now iam getting full details including street name. How can i get only city, state, country? I don\'t want

6条回答
  •  不知归路
    2021-02-18 19:54

    Use the following methods on the objects from addresses:

    getLocality()

    getCountryName()

    Use

    getAdminArea() to return state.

    I do not know how accurate this is for other countries but for addresses in the USA, this returns the correct state name.

    P.S. Sorry for writing a whole separate answer, I am not able to make comments yet.

提交回复
热议问题