in Android :
I want to use the method : getLoaderManager.initLoader() with API level 10 .
I know that this method requires API Level 11 or higher and i tried to use Android Support package but this package doesn't have this method .
what can i do ??
It sure looks to me like the Android Support Package has it. See the docs for android.support.v4.app.LoaderManager.initLoader().
Update:
For the equivalent of getLoaderManager, see getSupportLoaderManager.
You can increase the minimum SDK to level 15 and it will work fine.
Related
What is the difference between
android.util.ArraySet
android.support.v4.util.ArraySet
All methods seem to be identical.
As the page indicates, android.util.ArraySet was added in API level 23. android.support.v4.util.ArraySet is a copy in the backwards-compatibility support library, which allows you to use the class on older devices as far back as API level 4 (increased to level 14 in recent releases).
I'm getting an error after using this
StackOverflow answer:
setSelectionFromTop() requires API level 21 (current min. is 10)
and When I checked android API, it was added in API Level 1. How can I solve it?
After some googling it seams that yeah, it's a bug...
https://code.google.com/p/android/issues/detail?id=172621
As #pelotasplus says it's a bug and seems google still doesn't solve it till now. You can add #SuppressLint("NewApi") annotation to prevent lint check. See https://developer.android.com/studio/write/lint.html#src
I am confused about the target build and sdk usage
Lets say I have this code
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
//do xyz
}
Let say that I built against API 19 (kitkat) and my target api in manifest is 19 and my minimum supported api is 9
Now if a device with API 9 runs the above code, will it crash? I expect the answer is yes becasuse it will not understand what Build.VERSION_CODES.KITKAT means. However, what's the point of the check above then in first place?
Please help clarify this
Thank you
It won't crash. Simply the code within the if won't be executed. Build.VERSION_CODES.KITKAT is a constant field, and as you can read here, the constant fields are replaced with the numbers themselves by the compiler.
lesser versions of android will use the support library, if the check for kit-kat fails, it will revert to the closest possibkle form that version supports.... via the support library...
you cannot run you app on anything less than the minimum version, but it will find a way to run with less than the target version as long as its aboe the minimum
No, it won't crash, because its Build.VERSION.SDK_INT value is 9. It simply will not enter inside your if clause. Only devices that have API version 19 or above will run your code inside the if. Build.VERSION_CODES.KITKAT is equal to 19.
The code you posted won't crash because the class Build is created and compiled for every build of your app (as the R file) depending of the target API you set in the manifest
As you setup your target API to 19, the Build class will contain the field Build.VERSION_CODES.KITKAT because it exists starting from API level 19.
What does Advanceable Added in API level 16 mean? And how to use those two methods in Advanceable Api?I saw this interface in Launcher source code. I am not clear about the specification in android docs.Thanks.
It means that only devices with api level 16 or above knows/can use that method/class. And will fail to run if you put the code under a device with api level 15 or lower.
I downloaded ActionBarSherlock 4.0.3, unzipped it and created a new project from the library folder. The src folder was, according to Eclipse, full of errors, so I followed various instructions online, like adding android-support-v4.jar, setting target API to 15 and compiler compliance level to 1.6. Still, the project has 194 errors, all of which are "Call requires API level 11 (current min is 7)". So when I look at one of the errors, I see this:
#Override
public void invalidateOptionsMenu() {
getSherlock().dispatchInvalidateOptionsMenu();
}
public void supportInvalidateOptionsMenu() {
invalidateOptionsMenu();
//the previous line has this error in Eclipse:
//Call requires API level 11 (current min is 7): android.app.Activity#invalidateOptionsMenu
}
This looks strange to me, because invalidateOptionsMenu() is overridden with the previous function, but Eclipse still complains about the function requiring a newer API level. When I look at the other errors, I find that this is the case with many other errors too.
I have much more experience with Python than Java, so I don't understand anything of what causes this to happen. Help would be appreciated, and if you do help, could you also explain what causes this and what you did to solve it? I wouldn't want to ask someone every time I have a problem, I want to learn too.
Happened to me after running Lint checks. Try right click on sherlock action bar project -> Android tools -> Clear Lint Markers.
Use ActivityCompat, provided in the support jar.
Since you're using min API level 7, and invalidateOptionsMenu() did not exist until API level 11, you can't override it without errors since if the device runs API level 7, the function isn't even available in the base class and a non existing function cannot be overridden.
All this answers are wrong Except dbrown0708 Answer but I will declare it more
You Can use invalidateOptionMenu in lower API by using ActivityCompat As it provided in support library v4
Syntax is invalidateOptionsMenu(Activity activity);
code is
ActivityCompat.invalidateOptionsMenu(this);
In API Since level 11
invalidateOptionsMenu();
Try and use the import android.support.v4.app.Fragment; as your library