目录

SearchIntent

Class Info

public class SearchIntent

widget提供的SearchIntent类,用于拉起地点搜索建议组件。

Public Field Summary

Qualifier and Type

Field and Description

static final int

SEARCH_REQUEST_CODE

搜索请求码,值为1。

Public Constructor Summary

Constructor Name

SearchIntent()

默认的构造方法。

Public Method Summary

Qualifier and Type

Method Name and Description

Intent

getIntent(Activity mainActivity)

获取跳转到搜索组件所在页面的Intent。

Site

getSiteFromIntent(Intent data)

从Intent里获取Site对象。

SearchStatus

getStatusFromIntent(Intent data)

从Intent里获取错误信息SearchStatus对象。

static boolean

isSuccess(int resultCode)

检查resultCode是否是成功。

void

setApiKey(String apiKey)

设置SearchIntent的API密钥,必选。

void

setHint(String hint)

设置搜索框的默认文本。

void

setSearchFilter(SearchFilter filter)

设置搜索的限制条件。

Public Methods

[h2]getIntent

Method

public Intent getIntent(Activity mainActivity)

获取跳转到搜索组件所在页面的Intent。

Parameters

Name

Description

mainActivity

应用程序组件。

Returns

Type

Description

Intent

调用搜索组件页面的Intent。

[h2]getSiteFromIntent

Method

public Site getSiteFromIntent(Intent data)

从Intent里获取Site对象。

Parameters

Name

Description

data

Intent。

Returns

Type

Description

Site

被选中的Site对象。

Throws

Name

Description

NullPointerException

如果data是null,抛出异常。

IllegalArgumentException

如果data实例中的Site对象是null,抛出异常。

[h2]getStatusFromIntent

Method

public SearchStatus getStatusFromIntent(Intent data)

从Intent里获取错误信息SearchStatus对象。

Parameters

Name

Description

data

Intent。

Returns

Type

Description

SearchStatus

错误信息对象。

Throws

Name

Description

NullPointerException

如果data是null,抛出异常。

IllegalArgumentException

如果data实例中的SearchStatus对象是null,抛出异常。

[h2]isSuccess

Method

public static boolean isSuccess(int resultCode)

检查resultCode是否是成功。

Parameters

Name

Description

resultCode

返回码。

Returns

Type

Description

boolean

如果resultCode=0,返回true;否则返回false。

[h2]setApiKey

Method

public void setApiKey(String apiKey)

设置SearchIntent的API密钥,必选。

Parameters

Name

Description

apiKey

设置API密钥。

Throws

Name

Description

IllegalArgumentException

如果apiKey是null,抛出异常。

[h2]setHint

Method

public void setHint(String hint)

您调用此API可以设置搜索框的默认文本。

Parameters

Name

Description

hint

搜索框的默认文本。

[h2]setSearchFilter

Method

public void setSearchFilter(SearchFilter filter)

您调用此API可以设置搜索的限制条件。

Parameters

Name

Description

filter

SearchFilter对象,地点搜索的限制条件。

Throws

Name

Description

IllegalArgumentException

如果filter是null,抛出异常。