Get rid of lint TargetApi warnings

This commit is contained in:
Daniel Martí 2014-03-10 18:30:42 +01:00
parent be4db93da5
commit 54d7849191

View File

@ -9,15 +9,9 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
@TargetApi(14)
// aka Android 4.0 aka Ice Cream Sandwich // aka Android 4.0 aka Ice Cream Sandwich
public class NfcNotEnabledActivity extends Activity { public class NfcNotEnabledActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = new Intent();
if (Build.VERSION.SDK_INT >= 16) {
/* /*
* ACTION_NFC_SETTINGS was added in 4.1 aka Jelly Bean MR1 as a * ACTION_NFC_SETTINGS was added in 4.1 aka Jelly Bean MR1 as a
* separate thing from ACTION_NFCSHARING_SETTINGS. It is now * separate thing from ACTION_NFCSHARING_SETTINGS. It is now
@ -25,13 +19,28 @@ public class NfcNotEnabledActivity extends Activity {
* needed for NDEF. Therefore, we detect the current state of NFC, * needed for NDEF. Therefore, we detect the current state of NFC,
* and steer the user accordingly. * and steer the user accordingly.
*/ */
@TargetApi(14)
private void doOnJellybean(Intent intent) {
if (NfcAdapter.getDefaultAdapter(this).isEnabled()) if (NfcAdapter.getDefaultAdapter(this).isEnabled())
intent.setAction(Settings.ACTION_NFCSHARING_SETTINGS); intent.setAction(Settings.ACTION_NFCSHARING_SETTINGS);
else else
intent.setAction(Settings.ACTION_NFC_SETTINGS); intent.setAction(Settings.ACTION_NFC_SETTINGS);
} else if (Build.VERSION.SDK_INT >= 14) { }
// this API was added in 4.0 aka Ice Cream Sandwich // this API was added in 4.0 aka Ice Cream Sandwich
@TargetApi(16)
private void doOnIceCreamSandwich(Intent intent) {
intent.setAction(Settings.ACTION_NFCSHARING_SETTINGS); intent.setAction(Settings.ACTION_NFCSHARING_SETTINGS);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = new Intent();
if (Build.VERSION.SDK_INT >= 16) {
doOnJellybean(intent);
} else if (Build.VERSION.SDK_INT >= 14) {
doOnIceCreamSandwich(intent);
} else { } else {
// no NFC support, so nothing to do here // no NFC support, so nothing to do here
finish(); finish();