I'm just starting to do Android development, more-or-less following the http://developer.android.com/training/basics/firstapp/starting-activity.html tutorial, and one thing keeps bugging me: I have two classes, both created using the "Android Activity" creation wizard:
public class PlacesActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_places);
// I manually commented out the following line to get it to compile.
// getActionBar().setDisplayHomeAsUpEnabled(true);
}
// ... other methods
}
and
public class ShowOnePlace extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_one_place);
getActionBar().setDisplayHomeAsUpEnabled(true);
}
// ... other methods
}
Eclipse kept giving me the following errors:
Call requires API level 11 (current min is 8): android.app.Activity#getActionBar
Call requires API level 11 (current min is 8): android.app.ActionBar#setDisplayHomeAsUpEnabled
until I commented out one of the lines (as shown above). Now the application seems to compile and run on my Android device without errors. (Well, at least without that error).
So:
getActionBar().setDisplayHomeAsUpEnabled(true);
give that error in one class, but that exact same line is not an error -- not even a warning -- in the other class?getActionBar().setDisplayHomeAsUpEnabled(true);
statement is wrong in one activity, but perfectly fine in the other?When you upload an APK, it must meet Google Play's target API level requirements. New apps must target Android 12 (API level 31) or higher; except for Wear OS apps, which must target Android 11 (API level 30) or higher.
Step 1: Open your project in Android mode then go to Gradle Scripts > build. gradle(Module: app) as shown in the following image. Step 2: Refer to the below image and here you have to change the minSdkVersion and targetSdkVersion as per the requirement.
Uses of API Level in Android. The API Level identifier serves a key role in ensuring the best possible experience for users and application developers: It lets the Android platform describe the maximum framework API revision that it supports. It lets applications describe the framework API revision that they require.
Use getSupportActionBar()
instead of getActionBar()
. That will provide ActionBar features on API levels below 11.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With