Search code examples
smsjava-mewma

J2ME do cellphones have an auto-disable feature for non-compatible Packages?


I'd like to know if, for instance, I develop an App with both WMA Packages (1.1 and 2.0) and then deploy it to an older phone model with only WMA 1.1 support, will the Phone disable the 2.0 Package?

The code doesn't differ for what it's set to do between packages, but the 2.0 package gives extra functionality to that code which ends up being optimal for more recent phones.


Solution

  • I'd consider using Class.forName to load appropriate code depending on whether device supports WMA 2 or not

    class SpecificFeatureFactory {
        SpecificFeature get(boolean isWma2) {
            return (SpecificFeature)Class.forName(isWma2 ? "Rich" : "Poor");
        }
    }
    
    class Rich implements SpecificFeature {
        @Override
        long doSomething(String className, Date dateAlarm) throws Exception {
            return PushRegistry.registerAlarm(className, dateAlarm);
        }
    }
    
    class Poor implements SpecificFeature {
        @Override
        long doSomething(String className, Date dateAlarm) throws Exception {
            return -1;
        }
    }
    
    interface SpecificFeature {
        long doSomething(String className, Date dateAlarm) throws Exception;
    }
    

    Per my recollection WMA spec describes how application can determine whether it's 1.1 or 2.0.