Search code examples
javaandroidcordovahardware-acceleration

How to enable hardware acceleration depending on a device


I am getting this error:

E/libEGL(11261): call to OpenGL ES API with no current context (logged once per thread)

I found out that a possible solution would be to use

android:hardwareAccelerated="true"

But the issue is that I want to run the app on android 2.2 up.

If I add that setting to the AndroidManifest.xml, it won't compile because it will give an error.

Is there a way to enable that option based on device version, or maybe use a different solution?

I am using phonegap.

edit:

found the solution, i didn't had the deviceready listener running


Solution

  • Try with this .

     if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
    getWindow().setFlags(
                        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        (your view)view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
    

    AndroidManifest.xml

      <application
            android:hardwareAccelerated="true">