Swiftype Android Client Library
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
libs
res
src/com/swiftype
.gitignore
AndroidManifest.xml
LICENSE
README.md
SwiftypeAndroid.iml
lint.xml
logo-site-search.png
proguard-project.txt
project.properties

README.md

Elastic Site Search Logo

A first-party Android library to add Elastic Site Search to Android applications.

Contents


Getting started 🐣

Note: This client has been developed for the Swiftype Site Search API endpoints only. You may refer to the Swiftype Site Search API Documentation for additional context.

  1. Import SwiftypeAndroid into your workspace.
  2. In the properties for your application select 'Android' and add the imported project as a library
  3. Choose a search activity:
    • If your Swiftype search engine is crawler-based or WordPress-based and you would like to display results in a web view, use WebSearchActivity.
    • If you have an API-based engine, or would like different result display behavior, extend SearchActivity and create a custom ShowDetailsFragment to present the results.
  4. Add the search activity to your AndroidManifest.xml (example for WebSearchActivity):
        <activity
	      android:name="com.swiftype.android.search.webbased.WebSearchActivity"
		  android:label="@string/app_name"
		  android:windowSoftInputMode="stateAlwaysHidden"
		  android:exported="false"
		  android:launchMode="singleTop" >
		  <intent-filter>
		    <action android:name="android.intent.action.SEARCH" />
		  </intent-filter>

          <meta-data
		    android:name="android.app.searchable"
		    android:resource="@xml/searchable" />
    	</activity>
  1. Make it the default search activity for your application by adding the following lines to your main activity:
        <meta-data
		  android:name="android.app.default_searchable"
		  android:value="com.swiftype.android.search.webbased.WebSearchActivity" />
  1. Copy /res/values/swiftype_config.xml and /res/values/colors.xml (if you use a light theme) from SwiftypeAndroid. You must set the values for search_content_provider_authority and engine_key.
  2. Copy /res/xml/searchable.xml from SwiftypeAndroid to your project.
  3. Add android:configChanges="orientation|screenSize" to the application attributes in AndroidManifest.xml.
  4. Add the search provider and service to your AndroidManifest.xml:
        <provider
          android:exported="false"
          android:authorities="@string/search_content_provider_authority"
          android:name="com.swiftype.android.search.backend.SearchContentProvider" />

        <service
          android:name="com.swiftype.android.search.backend.SearchService" />
  1. Add Internet permissions to your AndroidManifest.xml:
		<uses-permission android:name="android.permission.INTERNET" />
  1. Use a SearchView or the SearchDialog to start a search. For an example, look at our SwiftypeAndroidExample repository. More information can be found in the Android Documentation.

FAQ 🔮

Where do I report issues with the client?

If something is not working as expected, please open an issue.

Where can I learn more about Site Search?

Your best bet is to read the documentation.

Where else can I go to get help?

You can checkout the Elastic Site Search community discuss forums.

Contribute 🚀

We welcome contributors to the project. Before you begin, a couple notes...

License 📗

MIT © Elastic

Thank you to all the contributors!