Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Words to Android's UserDictionary

Tags:

android

I want to add an entire medical dictionary to my android phone (Moto Droid). I would like to be able to send text messages and have the medical words be in the predictable text.

I've been trying to write a small app that would accomplish this, but everything I try the app crashes on startup. I've never written an app for a mobile platform so that is a first for me. Here is what is not working properly.

public class WordAdd extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    UserDictionary.Words.addWord( this , "newMedicalWord", 1, UserDictionary.Words.LOCALE_TYPE_CURRENT);
}

}

It seems so simple to do, yet I am so stuck. Thanks for any help you can provide.

EDIT: I should mention that I am getting this error for Android 2.1 in the AVD (virtual device).

EDIT 2: User Dictionary is found in the Android API. addWord is a static method. I don't declare UserDictionary because I just use the one static method. It's been ages since I developed anything in Java and this is my first attempt at any mobile development, so I don't know if I am doing something wrong.

like image 767
SaulBack Avatar asked May 22 '10 16:05

SaulBack


1 Answers

Add this to your app's AndroidManifest.xml file outside of the <application> element:

<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY"></uses-permission>
like image 119
bpsilver Avatar answered Oct 05 '22 21:10

bpsilver