Develop Android's application for all the versions - java

i'm developing an android application and i don't know how to make it compatible with all the versions. In eclipse i select only one API level, and in androidManifest i tried to put minSdk and MaxSdk covering all the version, but it crashes on some OS with different version.
How can i make it compatible with all the versions? Can you help me?

Do you really need to support all versions? Check out this chart, which the Android team updates monthly, and tells you what percentage of devices are running which Android versions. As you can see, 97% of devices are on Android 2.1+
I recommend supporting only Android 2.1+ (API level 7) if you can.
Android Platform Versions

I'd say that you'll make life really hard for yourself by attempting to make your application work on antiquated Android versions (and by that I mean 1.5 and 1.6). As Sky mentioned, only target Android 2.1 and above.
Can you please specify what exception is being thrown when you attempt to run the application on a different version of the OS?
Here's my application's definition in the manifest.
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10">
Defining it that way does not guarantee that your application will work on Froyo, Gingerbread and Gingerbread_MR1. Here's an example, I can't use requestSingleUpdate() from the LocationManager class in my application because it was only added in API level 9 (and I intend my application to work in API level 8!).
You need to ensure that you use functionality that is in API level 8 and below. Does that make sense?

Related

Using multiple sdk versions in my project

I am currently working on an app using some features that are only accessible in android 9.
I want to distinguish between users that have android 9 and can thereby use these features and users that are on 8.1 or lower for which I have to find an alternative solution.
Based on this information I want to call either the version with the features coming with android 9 or an alternative version that every smartphone can use.
My question now is, is it possible to create a project that contains android 9 "classes" but never get called when the device it is running on is 8.1 or lower.
Or is it not even possible to compile this project for a SDK version below android 9.
I am thankful for every answer.
Just check the Build version like this...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) ...

About new methods and deprecated methods in Android APIs

I'm new to android development.
I'm studying with outdated books, so I'm really confused about new methods.
I'm going to make a simple and light app which can be run even on old devices.
So when I created a new android project, I set "Minimum Required SDK" to API 8, "Target SDK" to API 22 and "Compile With" to API 22.
Does this setting mean the app can work on the devices of API 8, even though I use the methods of API 22?
I'm asking this question due to deprecated methods.
I completed almost a half of my app developing using deprecated ones.
Can I just replace them all with new ones?
Or do I have to prepare multiple codes using different methods to support different platform versions?
(deprecated methods for older versions, and new ones for newer versions?)
Does this setting mean the app can work on the devices of API 8, even though I use the methods of API 22?
Yes. min sdk version is used to restrict the devices running OS with API level < minsdk from using app. Your app won't be shown in the play store for those devices.
I'm asking this question due to deprecated methods.
I haven't faced any issues till now due to depreciated methods. However, I would suggest to use min sdk version as 14 as Google has introduced many UI tweaks and enhancements. If you do some market research, using minsdk version = 14 would cover around 85% android market.
Can I just replace them all with new ones?
Yes, you can.
Or do I have to prepare multiple codes using different methods to support different platform versions?
(deprecated methods for older versions, and new ones for newer versions?)
You can do it also. Older versions do not have support have fragments. Fragments improve user experience drastically for tablets. Similarly, material design for Lollypop devices is awesome. Thee are few examples where you can opt for API level specific implementation. However, it is better to switch for api level >= 14
To clear up your confusion:
Minimum Required SDK
The minimum version of Android you're going to support. To target the largest market share, I recommend API level 14 or above.
Generally, the lower the number, the more Android devices you're targeting.
Target SDK
Basically, all this is saying is what SDK have you tested your app with. If that's KitKat then you can write in the number 19 which is the API number of KitKat, for example. You can find a list of API numbers here. As you test your app with higher and higher versions of Android, you can increase that number.
Setting the Target SDK to be a higher number will mean that you target a lot more devices.
Compile With
Specifies what API number of Android you want to compile your app with.
By default this is the latest version of Android available in the SDK Manager. Should be set high to improve user experience.
Deprecated Methods
As to your question about deprecated methods: You can continue using them. They are deprecated in favour of a newer alternative that may or may not be better in terms of functionality.
Deprecated methods will still work, the deprecated keyword just tells you that there is a newer preferred way to do it. Android is really good at backward compatibility so something compiled for API level 8 should mostly work on newer devices to.
You're going to have to use multiple code branching on version. You can check your system version at runtime like this:
private void setUpActionBar() {
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
API 8 is really old. Have a look at the version pie chart
You can find more information about this on the Android developers website

blackberry's j2me configuration and profile

I'm sorry for asking a none-programming question, if it is.
I'm working on a library project that must be compatible through various mobile platforms.
I found some Java TV platforms are constructed on CDC/PBP.
I found Android api (partially) based on the Java 6.
And I want to know, is blackberry sill on the CLDC/MIDP?
According to Programming the BlackBerry With J2ME, it seems so.
Yes, they support MIDP 2.0/CLDC 1.1 and a good number of JSRs. Devices running OS 5.0 and higher have MIDP 2.1 support. Also there are the RIM custom APIs some of which can be used in BlackBerry MIDlets too.
More info here.
UPDATE:
For the new BB10 OS there's the possibility of repackaging an already existing Android app so that it can be run (with some issues) in the Android Runtime.

about older android versions on google market

I have developed my app in android 2.2, and put it on google market (munspel-appen).
I could see in the statistics that 4% are using android version 2.1 i dont have access to such device, so I wonder if my app will still work on that older version device if downloaded from market too or is it only working from 2.2 and up? How can one tell?
The configuration of your app (https://play.google.com/store/apps/details?id=com.munspel.munspelappen) seems to limit the app to devices with 2.2 and higher.
Users with a lower OS Version then 2.2. can not download your app from google market.
I would test your App in an Android 2.1 Emulator and if it works there change the minSDK for your app to 2.1 and upload an update to the market. In that way your app will be available to as much users as possible.
you can try in the android emulator in eclipse for example
Your application may work for 2.1 version provided that your application is compatible with API Level 7.
Well you can specify android:minSdkVersion=8 in AndroidManifest, (from document)The Android system will prevent the user from installing the application if the system's API Level is lower than the value specified in this attribute, You can try running your application on Emulator running 2.1 version. read more http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#uses
If you're willing to pay, there are several companies specializing in testing Android apps on physical devices. Examples:
http://duarlander.ning.com
http://www.perfectomobile.com
I think there's a lot more in google.
First, the Market should use the minSdkVersion in your Manifest to filter the apps when searched.
To test, you can use an emulator of version 2.1 and see whether it works.
Most probably most of the code will work except those new in 2.2.

Java Application on Smartphone

What alteration should be made in a Java Application to be able to install it on Java Enabled Smartphone?
I tried using a random app of mine to see what happens, when I open it on the cell, it says Install? I say yes, and it says invalid file.
Now I was wondering what alteration should be made?
My smartphone (Samsung S8500) runs on bada which is more or less the same as Android, but alterations in the General.
You need different SDK for smartphones. Like for Android, you need Android SDK 1.5 or any other version. You just cannot install the same application. You need to develop using the resources provided by the SDK.
If your application is Java based mobile application then you can use some tools to convert it for Android. Doesn't work every time but worth a try.
In your case, Bada OS is not like Android what i learn from here. So, you need to develop the application using J2ME .

Categories

Resources