Just for more information, those annotations are just for the compiler.

Saying "target API 12" notifies the compiler that I am aware the app will
run on pre-API 12 devices and that I have made sure the API 12
functionality will not be called for earlier devices. The @Override
annotation notifies the compiler that the method is being intentionally
overwritten, and is likewise ignored at runtime.

In this case, I'm using the onGenericMotionEvent method (or something like
that)... Well, it's only called from Activities that are API12+, so we are
safe since lower APIs just don't call it. The only other thing I did was
the if statement that checked if we treat joystick motion events as analog
controls, in which case we absorb the DPAD button presses from the
joysticks since the PSP uses the analog input.

One last thing, let's say we used @TargetApi on a method that IS harmful to
lower APIs and called it anyways on 2.2. Well, we'd crash with a
MethodNotFound exception or something, but it would still compile and try
to run on the device. Once again, in this case there should be 0 chance of
that happening.

I'll get back to you with the test results.

--Jamie Halpern
On Mar 21, 2013 8:33 AM, "James Halpern" <james.halpern@xtremelabs.com>
wrote:

> Nope! Not true. It should remain compatible down to 2.2 with just the one
> file. I'll test it today on 2.2 to confirm.
>
> --Jamie Halpern
> On Mar 21, 2013 3:02 AM, "Henrik Rydgård" <notifications@github.com>
> wrote:
>
>> In android/src/com/henrikrydgard/libnative/NativeActivity.java:
>>
>> > +		case KeyEvent.KEYCODE_DPAD_RIGHT:
>> > +			// Joysticks are supported in Honeycomb MR1 and later via the onGenericMotionEvent method.
>> > +			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1 && event.getSource() == InputDevice.SOURCE_JOYSTICK) {
>> > +				return false;
>> > +			}
>> > +		default:
>> > +			// send the rest of the keys through.
>> > +			// TODO: get rid of the three special cases above by adjusting the native side of the code.
>> > +			Log.d("JAMIE", "Key code: " + keyCode + ", KeyEvent: " + event);
>> > +			NativeApp.keyDown(keyCode);
>> > +			return true;
>> > +		}
>> > +	}
>> > +
>> > +	@Override
>> > +	@TargetApi(12)
>>
>> http://tools.android.com/recent/lintapicheck
>>
>> Appears it's just a lint check. That means that we must pull this code
>> out into its own class somehow, and only load that on 12+. Nasty.
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/hrydgard/native/pull/54/files#r3465869>
>> .
>>
>