Good point.  One trick you can do is to define an interface in the platform
that actually contains the method, and have Activity inherit from it.
 Current apps compiled against the old SDK would have their method bound to
the class, not the interface, so if my understanding of Java is not wrong
then they wouldn't get mixed.

It just didn't cross my mind to do that here; I probably should have.

On Fri, Feb 12, 2010 at 4:01 PM, Mike Collins <[email protected]>wrote:

> Ran into the below issue and wanted to see what solutions people
> have...
>
> In SDK 1.6 Activity did not have a method onBackPressed (), in 2.0 it
> appeared.
> Using the current docs I added an onBackPressed to a couple of our
> classes.
> We build against 1.6 (customer requirement) it seemed a bit odd that
> the compiler
> got upset when I put in a @Override, so I took it out and proceeded to
> verify that
> everything was working, which it was, the method was being invoked
> exactly as
> expected.
>
> Turns out this works only on phones/emulators with 2.0 or greater
> firmware.  On
> 1.6 firmware it fails to function at all because nobody calls it.
>
> OK, with hindsight it's obvious what's happening and we've made the
> @Override
> an error not a warning.
>
> But it raises the issue of how to I protect my app if in the future
> Android implements
> a method that collides with the name of method I invent for my derived
> class.  In
> this case Android will be calling my method at inappropriate times and
> expecting
> it to do things that it probably doesn't do.
>
> One solution is prefix every method of ours of every class that
> derives from an Android
> class with something specific to the app.  Or use a different naming
> convention, like
> always use an initial capital or an underscore etc.
>
> thoughts?
>  mike
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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