Reputation: 2249
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.
Upvotes: 2
Views: 116
Reputation: 6229
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
.
Upvotes: 2
Reputation: 285
If size isn't an issue you don't have to necessarily use preprocessing. If you don't use classes that are only present in WMA 2.0 you will just be tripping on NoSuchMethodErrors. Consider doing this.
public void doSomeThing()
{
try{
callWMA2_0Method();
}
catch( NoSuchMethodError e )
{
// We're WMA 1.1 then
callWMA1_1Method();
}
}
You can of course only compile against WMA 2.0 of course. But that shouldn't be a problem
Upvotes: 1
Reputation:
It will be an error on the older phone, that does not support new functionality.
Use Preprocessor to compile different versions for old and new phones from one package of source code.
Upvotes: 1