How to make a project compatible with different sdk versions when using functions for a specific version

I am developing a project that uses Flash video in web browsing. I solved all my problems regarding code, but only worked below Honeycomb.

Reading this I found out how to solve problems for Android 3.0 and later (including ICS), but now this is a big question ... If I make my project compatible with ICS, I need to use the directive, but then I would not work on gingerbread.

To provide more information ... a problematic piece of code:

android:hardwareAccelerated="true" 

which is a property included in Android 3.0.

So, is there anything I can do to avoid creating two different apks (somehitng like pre-HoneyComb apk and post-HoneyComb apk)?

This is part of my Android manifest:

 <application android:label="@string/app_name" android:icon="@drawable/elabora" android:theme="@android:style/Theme.NoTitleBar"> <activity android:name="es.fundacionvodafone.elabora.android.controlador.InicioElaboraTest" android:label="@string/app_name" android:noHistory="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="es.fundacionvodafone.elabora.android.controlador.InicioElabora" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:hardwareAccelerated="true"> <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> 

Thanks in advance.

Update: I already used what Mike explained, so to speak, correctly defined minSdk and targetSdk, but the following fact confused me. With this project configuration, when you run the project in eclipse, it asks for the following window: Capture of eclipse running a project with a targetSdk above the device api level A red cross means that the targetDdk level of the project is higher than the device API level. Therefore, I thought that this simply does not work in this device, but the fact is that you can run it and work as expected.

+8
android eclipse flash webview
source share
2 answers

The comment put by the OP under his question (mainly due to the fact that targetSDK does not affect the compilation of the application) is completely incorrect! Sorry you're stupid.

In short, here is the purpose of declaring another targetSDK from minSDK: this means that you use functions with an SDK of a higher level than your minimum, but you have provided backward compatibility. In other words, imagine that you want to use a function that was only recently introduced, but this is not critical for your application. Then you installed targetSDK in the version in which this new function was introduced, and the minimum - for something lower, so that everyone can use your application.

To give an example, let's say you are writing an application that makes extensive use of gesture detection. However, each command that can be recognized by a gesture can also be executed using the button or from the menu. In this case, the gestures are "excellent" but not required. Therefore, you must set the target sdk to 7 ("Eclair" when the GestureDetection library was introduced), and the minimum SDK to level 3 ("Cupcake") so that even people with really old phones can use your application. All you have to do is make sure that your application has checked the version of Android it was running on before trying to use the gesture library so as not to try to use it if it does not exist. (Admittedly, this is a dated example, since hardly anyone still has a v1.5 phone, but there was a time when maintaining compatibility with v1.5 was really important.)

To give another example, you can use this if you want to use a function from Gingerbread or Honeycomb. Some people will receive updates soon, but many others, particularly those with older hardware, may remain stuck with Eclair until they purchase a new device. This will allow you to use some of the new interesting features, but not excluding part of your potential market.

There is a really good article from the Android developers blog on how to use this function, and in particular how to develop a check before using it, there is a function mentioned above.

To OP: I wrote this mainly for anyone who accidentally stumbles upon this question in the future.

+8
source share

I have a similar issue with android manifest version. For older phones, I want to have widgets in several predefined sizes, for new phones that support resizing. I want to have one resizable widget. Could not find a way to do this. Perhaps this is why Google came with support for multiple APKs .

The article by Adam Powell mentioned above does not apply to such versions. (excellent BTW article).

Edit : got a solution. The definition of widgets in the android manifest has a boolean 'enabled' attibute, which can be set from logical resource values. Resource values โ€‹โ€‹can have values โ€‹โ€‹for each version using resource directory names corresponding to standard versions. The problem is resolved.

+3
source share

All Articles