Applications, e.g. ebook readers and word games, may leverage on offline dictionaries to show the definitions of words.
You as Android developer may send a request from your Android application to the offline dictionary in order to retrieve the meaning of a word and show the definition to the user. The request has to be sent via a specific intent towards the offline dictionary.
Your application has to create an intent with an action equal to Intent.ACTION_SEARCH, using the package name of the target offline dictionary and adding the word to look for as extended data (SearchManager.QUERY) to the intent.
The following offline dictionaries are available in the Android Market:
Here is an example to show italian definitions. Make sure to install the latest version of the italian offline dictionary on your Android device.
General documentation about developing Android applications is available in Android Developers web site.
Let's start by some useful imports:
Now we create an intent to retrieve the meaning of word 'pace':
Note that in case the intent is not available, you may insert a dialog suggesting the user to download the offline dictionary.
The method isIntentAvailable() is defined as follows:
The offline dictionaries support a new intent from release 3.1 to start the CustomizeView activity. The user can enable/disable the optional parts of the word definition (e.g. synonyms and antonyms).
The new intent is named livio.intent.action.CUSTOMIZEVIEW.
In order to launch the Customise view activity, you can use the following code: