Friday, March 16, 2012

Re: [android-developers] Way to set android:vmSafeMode at runtime

On Fri, Mar 16, 2012 at 12:39 AM, William Ferguson
<william.ferguson.au@gmail.com> wrote:
> I seem to have several devices running foul of the JIT compiler in
> Froyo (see http://code.google.com/p/android/issues/detail?id=9281)
> The solution appears to be setting android:vmSafeMode="true" in my
> application element in the Manifest, and this seems to work well.

Note that this is a lightly-documented property on <application>, so
I'd keep a very close eye on future Android releases so make sure they
don't get rid of it, rename it, etc.

> But I don't really want to switch off JIT for everyone, just for the
> FROYO users.
> Does anyone know of a way to set vmSafeMode at runtime?

Create a boolean resource (e.g., @bool/safeModeEnabled). Define it in
res/values/ as true. Define it in res/values-v9/ as false. Use the
resource as the value of android:vmSafeMode. Then, at runtime, Android
will use the right value for the device. Technically, this uses safe
mode for API Level 8 *and lower*, but since I think JIT only showed up
in API Level 8, I doubt there will be an impact on lower API levels.

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

Warescription: Three Android Books, Plus Updates, One Low Price!

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

No comments:

Post a Comment