public class SearchManager
extends java.lang.Object
To implement search user need to follow these steps:
1. Add <uses-permission android:name="android.permission.INTERNET" />
in your manifest under <manifest>
tag
2. Add <meta-data android:name="com.tplmaps.android.sdk.API_KEY" android:value="YOUR_API_KEY" />
along with you API_KEY in your manifest under <application>
tag
3. Initialize an instance of SearchManager
class
4. Add a listener of your class with the instance by calling SearchManager#setListener(OnSearchResult)
5. Call request(Params, OnSearchResult)
method by setting at least Params.query
You will get response callbacks in your listener.
Note: Call request(Params, OnSearchResult)
for search query after an interval
of minimum 3 seconds because of network limitations applied on our servers otherwise all your request will be suspended
Constructor and Description |
---|
SearchManager(android.app.Activity activity)
Constructor to initialize object
|
Modifier and Type | Method and Description |
---|---|
void |
cancelPendingRequests()
To cancel all pending requests.
|
void |
onCreate() |
void |
onDestroy()
Remove listener
|
void |
request(Params params,
OnSearchResult listener)
Call this method by passing mandatory
Params while making request for a query string. |
public SearchManager(android.app.Activity activity)
activity
- Reference of an activitypublic void request(@NonNull Params params, @NonNull OnSearchResult listener)
Params
while making request for a query string.
Make sure that you're not requesting before 3 seconds(3000ms), your request will be suspended otherwise.
You will get results in corresponding callback method of OnSearchResult
listener interface.params
- an instance of Params
listener
- an instance of OnSearchResult
public void cancelPendingRequests()
OnSearchResult.onSearchRequestCancel(Params, long)
only when the listener is registered through RetrofitHelper.setListener(OnSearchResult)
public void onDestroy()
public void onCreate()