I have a J2ME app that can optionally use the GPS package (javax.microedition.location). So in the JAD I have that appropriate API permission set to Optional. However, even though this allows for the application to be installed on devices without GPS, if the user tries to use the GPS feature the app will crash because it can't find the package.
How can I programatically test if the javax.microedition.location exists within my application so that I can disable that feature without having two separate apps? I considered trying to instantiate the class that uses the location package then catching the exception as a sort of test, but I'm sure there is a better way.
For the record "import javax.microedition.location" doesn't seem to cause any issues. It only craps out when I actually try to use the package.