So assuming for a minute we go with Mark's solution and the abstract class; what target Android version should appear under the project's Properties -> Android tab? The latest API the app uses?
This is running on my emulator with Android 1.5, but will it work on an actual device? If the manifest file is defining what API level the app needed, what's the purpose of this Build Target? On Apr 20, 6:34 pm, Max Gilead <[email protected]> wrote: > Dianne, what's wrong with checking version number? > > Unless there's some problem with it I'd suggest going with Mark's solution > (also covered > inhttp://devtcg.blogspot.com/2009/12/gracefully-supporting-multiple-and...). > You can use it for most cases and it's much cleaner (and definitely stay > away from reflection-based one unless, for some reason, there's no other > choice). > > Cheers, > Max > > On 21 April 2010 01:43, Dianne Hackborn <[email protected]> wrote: > > > > > > >http://android-developers.blogspot.com/2009/04/backward-compatibility... > > > Or actually it appears this has become a tech article: > > >http://developer.android.com/resources/articles/backward-compatibilit... > > > <http://developer.android.com/resources/articles/backward-compatibilit...>The > > last section, "Using a wrapper class," talks about this. > > > On Tue, Apr 20, 2010 at 5:01 PM, Christopher < > > [email protected]> wrote: > > >> Diane, > > >> Can you please explain what blog post you're referring to in your > >> post? > > >> On Apr 20, 2:26 pm, Dianne Hackborn <[email protected]> wrote: > >> > I suggest not using the SDK version, but just use the trick in the blog > >> post > >> > to detect if the class doesn't exist before trying to use it. > > >> > On Tue, Apr 20, 2010 at 1:00 PM, kec6227 <[email protected]> wrote: > >> > > Oh ok, that makes perfect sense. Thank you. > > >> > > On Apr 20, 12:11 pm, Mark Murphy <[email protected]> wrote: > >> > > > kec6227 wrote: > >> > > > > Using? a wrapper class of sorts? If I initiate the > >> WallpaperManager > >> > > > > anywhere in my code, it will throw a VerifyError on older > >> platforms, I > >> > > > > tried something like this: > > >> > > > > if(Integer.parseInt(Build.VERSION.SDK) >= 5){ > >> > > > > WallpaperManager wallMan.. > >> > > > > ...blah blah > >> > > > > } > > >> > > > > The only way it does not throw a verifyerror is when I don't use > >> the > >> > > > > WallpaperManager anywhere. > > >> > > > That's not strictly true. You only will get a VerifyError if you > >> load a > >> > > > class that refers to WallpaperManager. > > >> > > > So, the trick is to use reflection or conditional class loading to > >> only > >> > > > load your code referencing WallpaperManager on suitable versions. > > >> > > > For example: > > >> > > > if(Integer.parseInt(Build.VERSION.SDK) >= 5){ > >> > > > new MyWallpaperBridge().goDoSomething(); > > >> > > > } > > >> > > > Or, create an interface and two implementations, and choose the > >> > > > implementation based on the version, as seen here: > > >>http://github.com/commonsguy/cw-advandroid/tree/master/Contacts/Spinn... > > >> > > > -- > >> > > > Mark Murphy (a Commons Guy)http://commonsware.com| > >> > >http://twitter.com/commonsguy > > >> > > > Android Training in US: 14-18 June 2010:http://bignerdranch.com > > >> > > > -- > >> > > > 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]><android-developers%2Bunsubs > >> [email protected]> > >> > > > For more options, visit this group athttp:// > >> > > groups.google.com/group/android-developers?hl=en > > >> > > -- > >> > > 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]><android-developers%2Bunsubs > >> [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]<android-developers%[email protected]> > >> > For more options, visit this group athttp:// > >> groups.google.com/group/android-developers?hl=en > > >> -- > >> 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]<android-developers%[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > 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 > athttp://groups.google.com/group/android-developers?hl=en -- 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

