Use conditional class loading to only reference hasVibrator() from
class that will be used on Honeycomb. You can see an example of that
here:

https://github.com/commonsguy/cw-android/tree/master/Menus/ActionBarBC

I have a HoneycombHelper class that uses getActionView() on MenuItem.
I only reference that class when I am on Honeycomb. Older devices
never load the class and therefore never get the VerifyError.

On Mon, Aug 1, 2011 at 2:42 PM, bbbreimmm <[email protected]> wrote:
> Hi!
>
> I'm currently working on an Android port of an iOS game for the studio
> I'm am working at. I am trying to incorporate the in-game vibration
> function we have inside the original project and I am kind of running
> into a wall with that right now. In our main menu screen we have an
> option for the user to turn on and off the vibration as he pleases. If
> the device cannot support that feature, we simply put an "unavailable"
> tag right next to it instead of the selection button. We want the
> application's minSdkVersion to be 4. Searching around the google group
> and Stack Overflow, I have found that prior to Honeycomb all devices
> should be equipped with this feature. On the other hand, for devices
> with API Level 11 and up I need to verify that the device the
> application is currently running on actually has a vibrator. I began
> writing this little code snippet:
>
>    public boolean CanVibrate()
>    {
>        int mCurrentApiVersion = android.os.Build.VERSION.SDK_INT;
>
>        if (mCurrentApiVersion >= 11 /
> *android.os.Build.VERSION_CODES.HONEYCOMB*/)
>        {
>                return mVibrator.hasVibrator();
>        }
>        else
>        {
>                return true;
>        }
>    }
>
> Since the hasVibrator() function didn't exist before HoneyComb, I fear
> the game will crash at runtime or will not boot at all on older
> versions... I have no idea how this verification can be made and work
> on all those very different devices. Any clue how this could be
> solved?
>
> Thanks in advance!
>
> --
> 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
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in NYC: http://marakana.com/training/android/

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