5

I am trying to implement the example shown on this page. I have tried on three different devices running android 4 and above, and in all cases I get a black screen with this warning:

01-27 20:01:22.683: W/TextureView(4728): A TextureView or a subclass can only be used with hardware acceleration enabled.

I have turned on hardware acceleration in the application manifest:

<application
    android:hardwareAccelerated="true"
    [etc...]

But the following check my custom view's onAttachedToWindow method always returns false

private class MyTextureView extends TextureView
{
    public MyTextureView(Context context) {
        super(context);
    }

    @Override
    protected void onAttachedToWindow()
    {
        super.onAttachedToWindow();
        Log.d("", Boolean.toString(mTextureView.isHardwareAccelerated()));          
    }
}

Does anyone know what is wrong here?

Thanks

tishu
  • 998
  • 15
  • 29
  • do you have hardware acceleration enabled in your manifest? – Leonidos Jan 27 '13 at 20:09
  • You can enable or disable it in your manifest. Usually you do this on a per activity basis. – Nathan Jan 27 '13 at 20:21
  • 1
    As mentioned in the original post, I have done so on the application level. According to the [hardware acceleration documentation](http://developer.android.com/guide/topics/graphics/hardware-accel.html), this is sufficient. – tishu Jan 27 '13 at 20:29
  • 4
    Did you figure this out? – Amitay May 22 '13 at 08:41
  • 1
    According to the following resource the canvas in TextureView is not hardware accelerated (still true as of Android 6.0): http://stackoverflow.com/questions/9966228/android-textureview-hardware-acceleration-with-lockcanvas/14987164 – sagis Dec 17 '15 at 09:03

1 Answers1

0

If you testing with Emulator then please check configuration for hardware acceleration. Please check this thread for more info: http://developer.android.com/tools/devices/emulator.html#acceleration

Kalpesh
  • 1,767
  • 19
  • 29