I have an android app which I started write on sdk 2.2, but my android phone has the 1.5 version of the android. I have to downgrade my app to 1.5 seamlessly. I am not fully sure but I didn't use too many 2.2-specific features. Can you tell me how to do it?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Essentially follow Jean's link from above to the dev blog and take those recommendations. You're going to create a singleton class that lazy loads the right class for the corresponding API level of the device its running on. Functions that are unavailable in a version should handle that use case.
This abstract class then will have some abstract methods it defines like
A class can be defined for each api level. EDIT: these are all private classes defined inside of the StaticAct.java file. This allows the lazy loading to work correctly and prevent instantiation from other classes.
The base class (extending the StaticAct) must implement all methods defined in StaticAct. If the method is unavailable for that api level then handle that case, throw an error or return false (or ignore it completely).
As your classes increase in api level they only need to implement methods that have changed from previous versions. So the multitouch APIs became available in 2.0, strict mode in 2.3 etc.
If you're using Eclipse, change the manifest's
minSdkVersion
andtargetSdkVersion
and project's setup to use 1.5 and anything that's not present in that version of the API will turn into an error.In your manifest.xml file:
See here for detailed information
The API level is inserted into the minSdkVersion, targetSdkVersion and maxSdkVersion fields (not that maxSdkVersion has been deprecated in the toolkit, but will work in the market). To synopsize: