我一直在尝试为 Android 构建天气应用程序,同时构建应用程序我想添加一个选项来按名称选择城市,而不仅仅是按坐标。我想添加一个自动完成部分,允许用户输入城市名称,他会获得具有该名称的城市的所有选项,稍后将转换为城市坐标。
我找到了谷歌地点 API,但它要花钱。 https://developers.google.com/maps/documentation/javascript/places-autocomplete。
我想知道是否有人知道自动完成城市名称及其坐标的免费 API 或 Android 库,或者是否可以在没有 API 密钥的情况下从谷歌检索城市名称
我一直在使用Room Persistence库,在我将其放入两个不同的插入项之前,它一直都很好用。
声音实体类
@Entity
public class Sound {
@PrimaryKey(autoGenerate = true)
private int sid;
@ColumnInfo(name = "sound_theme")
private int soundTheme;
@ColumnInfo(name = "sound_name")
private String soundName;
@ColumnInfo(name = "sound_resource")
private int soundResource;
@ColumnInfo(name = "sound_image_resource")
private int soundImageResource;
@ColumnInfo(name = "sound_favorite")
private boolean isFavorite;
@ColumnInfo
private int usedCount;
@ColumnInfo
private long lastUsed;
public Sound(int soundTheme, String soundName, int soundResource, int soundImageResource, boolean isFavorite, int usedCount, long lastUsed) {
this.soundTheme = soundTheme;
this.soundName = soundName;
this.soundResource = soundResource;
this.soundImageResource = soundImageResource; …Run Code Online (Sandbox Code Playgroud)