目录

SearchIntent

Class Info

public class SearchIntent

SearchIntent class provided by the widget, which is used to start the search suggestion widget.

Public Field Summary

Qualifier and Type

Field and Description

static final int

SEARCH_REQUEST_CODE

Search request code. The value is 1.

Public Constructor Summary

Constructor Name

SearchIntent()

Default constructor.

Public Method Summary

Qualifier and Type

Method Name and Description

Intent

getIntent(Activity mainActivity)

Obtains an intent for redirecting to the page where the search widget is located.

Site

getSiteFromIntent(Intent data)

Obtains a Site object from an intent.

SearchStatus

getStatusFromIntent(Intent data)

Obtains a SearchStatus (result information) object from an intent.

static boolean

isSuccess(int resultCode)

Checks resultCode to determine whether the search is successful.

void

setApiKey(String apiKey)

(Mandatory) Sets the API key of SearchIntent.

void

setHint(String hint)

Sets the default text in the search box.

void

setSearchFilter(SearchFilter filter)

Sets search criteria.

Public Methods

[h2]getIntent

Method

public Intent getIntent(Activity mainActivity)

Obtains an intent for redirecting to the page where the search widget is located.

Parameters

Name

Description

mainActivity

App component.

Returns

Type

Description

Intent

Intent for redirecting to the page where the search widget is located.

[h2]getSiteFromIntent

Method

public Site getSiteFromIntent(Intent data)

Obtains a Site object from an intent.

Parameters

Name

Description

data

Intent.

Returns

Type

Description

Site

Selected Site object.

Throws

Name

Description

NullPointerException

If data is null.

IllegalArgumentException

If the Site object in the data instance is null.

[h2]getStatusFromIntent

Method

public SearchStatus getStatusFromIntent(Intent data)

Obtains a SearchStatus (error information) object from an intent.

Parameters

Name

Description

data

Intent.

Returns

Type

Description

SearchStatus

Error information object.

Throws

Name

Description

NullPointerException

If data is null.

IllegalArgumentException

If the SearchStatus object in the data instance is null.

[h2]isSuccess

Method

public static boolean isSuccess(int resultCode)

Checks resultCode to determine whether the search is successful.

Parameters

Name

Description

resultCode

Result code.

Returns

Type

Description

boolean

true if the value of resultCode is 0; false otherwise.

[h2]setApiKey

Method

public void setApiKey(String apiKey)

(Mandatory) Sets the API key of SearchIntent.

Parameters

Name

Description

apiKey

API key.

Throws

Name

Description

IllegalArgumentException

If apiKey is null.

[h2]setHint

Method

public void setHint(String hint)

Sets the default text in the search box.

Parameters

Name

Description

hint

Default text in the search box.

[h2]setSearchFilter

Method

public void setSearchFilter(SearchFilter filter)

Sets search criteria.

Parameters

Name

Description

filter

SearchFilter object containing the search criteria.

Throws

Name

Description

IllegalArgumentException

If filter is null.