On May 28, 2:21 pm, Mike Hearn <[email protected]> wrote:
> So in future:
>
> import android.newapi.NewApi;
>
> public class MyActivity extends Activity {
>   public void onResume() {
>     if (BUILD.getSdkVersion() >= 4) {
>       NewApi newApi = new NewApi();
>     }
>   }
>
> }
>
> will work and this APK will install on older Androids (well, Androids
> after this change was made, but before the new api).

In the future, that will pass verification, with an "always throw"
instruction inserted where the "new" operation is now.  If it fails,
it will do so when executing rather than during class verification.
(Which, besides allowing stuff like the above to work as expected,
results in much more meaningful exception traces.)

FWIW, the recommended approach for old-vs-new APIs:

  
http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to