My App is coded with 2.2 "SdVersion 8" and when I run it in Ice Cream Sandwich I get the "Contex menu" down in botton right.
I want to take use of the new ICS interface. If I change the App to API-level 14 (Android 4.0) I get the new interface! (On 4.0 phone). BUT the App doesn't seem to start at all on phones with older Android-versions for example 2.2.
If I change minSdkVersion in the "API target 14" to 8 .. I get the old 2.2 interface on 4.0 devices.
So. Is it possible for an App to get the 2.2 interface on a 2.2 device, and 4.0 interface on a 4.0 device?
It is not possible to get the 4.0 interface on a 2.2 device without manually importing all of the resources you need from the Android source into your application and applying them correctly. The reason for this is all Android resources that are used to create the ICS theme are already on the phone. When you reference anything inside of the Android package you are actually referencing the Android version that is installed on a given device.
This is why for example when you open a dialog on an HTC device it looks different than it will on a Samsung device. Device manufactures usually customize some of these built in Android resources to give there device a special look than all other Androids.
So if you wanted to get the look of the ICS interface on all devices you could go into the android sdk you have downloaded and look in "pathToSDK/platforms/android-14/data/res". I would not suggest this as you might not get all of the required dependencies or you might have some conflicting styles that make it hard to see things. Also most users are comfortable with the theme they are used to seeing on their device and if there is an app that makes a major change to that it might take the user off guard.
Edit:
Sorry for my long winded answer as I think I misunderstood your question. You can get a 4.0 interface on a 4.0 and 2.2 interface on a 2.2 by setting the target sdk to 4.0 but leaving the min sdk on the lower setting. This is a deprecated doc but will explain how to do what you are looking for.
You can now also try the support library (appcompat v7 (library project), mediarouter v7 (library project), gridlayout v7 (library project), renderscript v8 (library jar), fragment backwards support v4 (library jar) v13 (library jar) ) from Google released with API Level 18. It can work all the way to 2.1 Eclair in some cases.
There is tutorials on how to import the library with Eclipse.
I have managed to do it with Netbeans Android plugin by adding it via the project properties in libraries section and then browse to the appcompat or other v7 project shown as android library project. The library jars are do
Related
I just started programming using Android Studio and it's so cute. But at first compile some errors occurred.
I added a Login Activity and found out that this activity does not support programming for older phones with API9.
Is there an Android Studio activities for lower version APIs such as API9 (Android 2.3.3) ?
The way to support earlier API versions is through the official Android Support libraries. Mostly these are backported versions of more recent features added in later API levels.
See http://developer.android.com/tools/support-library/index.html for more details.
If you create a new project using the Android Studio wizard and set the minimum SDK level to 9 for example, it will automatically include support library dependencies for you.
I want to know whether the Fragment Manager works in Android API 8 ? I am using the project to compile with Android API 8.
if yes tell me how to use the fragment in lower devices or suggest any tutorial links.
The Android Support Library backports many newer features to older Android versions. In the case of Fragments, they are supported via the support library back through Android 1.6 (API 4) as explained in the features overview. The setup instructions go through everything you need to include the Support Library in your application.
If I want to develop an app for API 7 through to 18. I understand I should set minSdkVersion to 7 in the manifest, and I assume I should set 18 as targetSdkVersion. But I'm confused by what SDK I should use for development. Should I be using the SDK for 2.1 (API 7) or 4.3 (API 18)? I don't want compatibility behaviours as I want to completely control and specify what to do on each platform version. And what about the support library? Would I use support libraries 8-18 or 1-7?
(Posted here because development questions are off-topic for android.stackexchange.com)
You can and should use the newest SDK. Eclipse or Intellij will automatically take care of letting you know if you are attempting to use a component that is only available in newer APIs. You will only want to use support library v7 and below since you intend on supporting API 7 and above. A lot of your worries will automatically be taken care of by your IDE. It will let you know if you are trying to use things that are not available in your minimum API level (which you indicate in your manifest file).
I am working on a Cordova Android project with barcode scanning ability. I find the detailed steps on this blog helpful: http://simonmacdonald.blogspot.ca/2011/12/installing-barcode-plugin-for-phonegap.html
However, I am a bit concerned about the mismatch of SDK target of barcodeScanner library (Android 4.0) and that of main project being 2.x. As 2.x is still dominant Android OS in the market, it makes sense to build main project targeting 2.x.
Will that barcodeScanner library targeting 4.0 work well on 2.x handset?
Am I missing something here?
Any pitfalls to watch out for? especially considering future code changes to adapt to fast changing Android handsets.
Don't worry about it. You always want to build your app against the latest version of the Android SDK. The SDK can handle the backwards compatibility aspects. If you want to target from Android 2.1 and higher set the minimum SDK to 7 in your AndroidManifest.xml.
I found a lot of online resources regarding targeting a variety of Android versions from my min-SDK version up through my target-SDK. This includes doing things like reflection or wrapper classes to test for the advanced functionality that may be available only in the higher Android version I'm targeting.
What I cannot figure out is how to get this to work in Eclipse. Specifically, the problem I am running into is that if I choose a Project Build Target that matches my target-SDK then Eclipse will not allow me to select an AVD with a lesser Android version for debugging/testing. Therefore I can't test the reflection tricks to make sure they work for backwards compatibility. The alternative of choosing the lowest Project Build Target means that I cannot refer to any of the advanced classes/methods available only in the newest Android versions without getting compiler errors.
What is the correct way to organize an Eclipse Android project to make targeting multiple versions work?
(P.S. I'm trying to use the old, undocumented calendar access tricks alongside the new ICS calendar API.)
Thanks!
project.properties includes your build target. set this to android-15 (latest API).
In the manifest set min-sdk to the minimum sdk you are supporting for example 8 (froyo). This is the minimum API and it will only launch on devices with API bigger or equal than this.
Make sure you test all API's which are lower than the target as some methods might not work. An example for this is the ActionBar introduced in Honeycomb - it will not work on API's lower than Honeycomb.