I want my app, which relies heavily on GPU, to use hardware acceleration. On some forums I've been suggested to set android:hardwareAccelerated="true"
inside <application>
and on other forums same attribute inside <activity>
inside my AndroidManifest.xml
. Below is the representation of what it looks like:
<application
...
android:hardwareAccelerated="true"
...>
<activity
...
android:hardwareAccelerated="true"
...>
</activity>
</application>
I ended up setting in both, yet I wonder, which one is the right way, and what is the difference?
Hardware acceleration is enabled by default so you don't have to set it unless you need to disable it. As said in the documentation:
Hardware acceleration is enabled by default if your Target API level is >=14, but can also be explicitly enabled.
To answer your question. Setting it on Application tag affects your whole application and setting it on Activity tag affects that activity.
In your Android manifest file, add the following attribute to the tag to enable hardware acceleration for your entire application:
<application android:hardwareAccelerated="true" ...>
If your application does not behave properly with hardware acceleration turned on globally, you can control it for individual activities as well. To enable or disable hardware acceleration at the activity level, you can use the android:hardwareAccelerated attribute for the element. The following example enables hardware acceleration for the entire application but disables it for one activity:
<application android:hardwareAccelerated="true">
<activity ... />
<activity android:hardwareAccelerated="false" />
</application>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With