| Reply | « Previous Thread | Next Thread » |
|
I wrote a MIDlet that uses JSR-120 functionality among other things. When I run it on a phone that doesn't support JSR-120 I get an error message for known reasons.
However, I want be able to run this code on a non-JSR120 phone while disabling the WMA(JSR-120) functionality. In other words, I want to be able to run the same code on a variety of devices and be able to detect in run time which functionality is not supported and just not use it. |
|
Taken from the Nokia block game example:
Code:
private GameEffects makeGameEffects()
{
try
{
Class.forName("com.nokia.mid.sound.Sound");
Class.forName("com.nokia.mid.ui.DeviceControl");
// If no exception was thrown, use the vendor-specific APIs.
Class clas = Class.forName("NokiaGameEffects");
return (GameEffects) clas.newInstance();
}
catch (Exception e)
{
// The vendor-specific APIs are not available,
// so use the 'stub' GameEffects instead.
return new GameEffects();
}
}
shmoove |
|
But shouldn't I also put an import statement at the beginning of the class
|
|
No. You are using Class.forName() so you shouldn't need it.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|