- Go to java project build path
- Add New External Jar
- Go to the installation location of your Android platform (usually C: \ Program Files (x86) \ Android)
In android-sdk \ platform \ android-x (where x is the version of your android) select the android.jar file to add to the project.
Now you have the android library under the reference libraries, and you can use all the classes for Android in your java project.
Another way to do this is to use the android source, get only the java files you need from the Android library, and put them in your java project. Well, when you do it this way, you can change the code and make it more compatible with your java work.
source share