问题
I'm trying to display animated GIF using WebView. It works fine on most devices, but still some of them doesn't support animations and a static GIF is displayed.
How can I detect if the device supports animated GIFs in WebView, so I can display appropriate message if it doesn't?
回答1:
Yeah, this seams to be a common issue. There are some workarounds posted in the Bug-report, but it seams that it's not an Android Core-feature.
Some company's (like HTC) maybe took care of this themselves, but you can't rely on animated gif's to work.
回答2:
As you can see with this link http://code.google.com/p/android/issues/detail?id=3422. this issue still unresolved for two yrs. But the most of the devices work fine in Gingerbread. So you might check the OS level (starting in level 9) which is works or not
回答3:
Hate to say it this way, but its the most effective way to find out. Open a GIF image, and if it doesnt play... Its not supported on the device
回答4:
Animated GIF support was added to Android in version 2.2. If you check the version using Build.VERSION, it should tell you whether the GIFs are working.
回答5:
In the Android C++ file external/webkit/WebCore/platform/graphics/android/ImageSourceAndroid.cpp
there is a function static bool should_use_animated_gif(int width, int height)
which returns true
if ANDROID_LARGE_MEMORY_DEVICE
is defined.
Here, Leon Scroggins (seems to be a Google engineer) says that ANDROID_LARGE_MEMORY_DEVICE
is defined "for all arm devices with a VFP, and all non-arm devices."
Edit: This is confirmed by external/webkit/Android.mk
:
ifeq ($(ARCH_ARM_HAVE_VFP),true)
LOCAL_CFLAGS += -DANDROID_LARGE_MEMORY_DEVICE
endif
In my understanding, all ArmV7 cpus do have a VFP, so animated GIFs should work on modern cpus with ArmV7.
来源:https://stackoverflow.com/questions/7713384/android-animated-gif