Overview

Applications, e.g. ebook readers and word games, may leverage on dictionary language packs to show the definitions of words.
You as Android developer may send a request from your Android application to the language pack in order to retrieve the meaning of a word and show the definition to the end user. The request has to be sent via a specific intent towards the language pack.

Your application has to create an intent with an action equal to Intent.ACTION_SEARCH, using the package name of the target language pack and adding the word to look for as extended data (SearchManager.QUERY) to the intent.

The following language packs are available in the Android Market:

LanguagePackage
English:livio.pack.lang.en_US
French:livio.pack.lang.fr_FR
Italian:livio.pack.lang.it_IT
Spanish:livio.pack.lang.es_ES

Example

Here is an example to show italian definitions. Make sure to install the latest version of the italian language pack on your Android device.

General documentation about developing Android applications is available in Android Developers web site.

Let's start by some useful imports:

import android.content.ActivityNotFoundException;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

Now we create an intent to retrieve the meaning of word 'pace':

String word = "pace";
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setPackage("livio.pack.lang.it_IT");
intent.putExtra(SearchManager.QUERY, word);
List lri = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if ((lri != null) && (lri.size() > 0)) // check if intent is available ?
    startActivity(intent);
else Log.d("demo", "Intent is not available!");

Note that in case the intent is not available, you may insert a dialog suggesting the end user to download the language pack.
Thesaurus | Terms and conditions | Privacy policy