1

I try into enable the acceration for my android app, but failed. my code as follows:

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="tsaarni.nativeeglexample"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="21"/>
    <application android:label="@string/app_name" 
         android:icon="@drawable/ic_launcher" 
         android:allowBackup="true" 
         android:hardwareAccelerated="true">
        <activity android:name="NativeEglExample"
                  android:hardwareAccelerated="true"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

And I also start window accerlation:

setContentView(R.layout.main);
getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

FrameLayout was created in a layout xml file, I get it but found the acceleration status ac is false:

  FrameLayout globalFramelayout = (FrameLayout)findViewById(R.id.my_framelayout);
  boolean ac = globalFramelayout.isHardwareAccelerated(); 

So, my questions are:

1. Is my judgement method correct?
2. If that's correct, why ac status is false ?
Chogri
  • 326
  • 3
  • 15
  • You enable it in the `AndroidManifest.xml`. – Jared Burrows Mar 23 '15 at 14:26
  • But why globalFramelayout.isHardwareAccelerated() is false? And how could I enable acceleration for globalFrameLayout? – Chogri Mar 23 '15 at 14:31
  • Hardware acceleration is only turned on if available. However, see: http://stackoverflow.com/questions/6792115/detect-hardware-acceleration-at-runtime-android. – Jared Burrows Mar 23 '15 at 14:34
  • Thanks for the link. But I'm still not verty clear that, if my Activity is AC-enalbed , will the FrameLayout inflated from a xml is default AC-enabled? How about a new created View? – Chogri Mar 23 '15 at 15:55
  • Why do you care about hardware acceleration? Are you running this on Android 3.0+ ?http://developer.android.com/guide/topics/graphics/hardware-accel.html – Jared Burrows Mar 23 '15 at 16:07
  • Cause my project need to compose a SurfaceView which rendered in native code by opengles and a Android WebView. The two views will be composed in a FrameLayout. For the sake of efficiency, I must ensure that the composition is AC-enabled. – Chogri Mar 24 '15 at 01:20
  • Alright. Besides those two links, I am not sure. Possibly no available? – Jared Burrows Mar 24 '15 at 02:39

0 Answers0