Setting android:hardwareAccelerated=“true” in or in
Setting android:hardwareAccelerated=“true” in <activity> or in <application>
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:
android:hardwareAccelerated="true"
<application>
<activity>
AndroidManifest.xml
<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?
2 Answers
2
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 set on <application>
it means that the whole app has the hardwareAccelerated
feature and you don't need to set it again on <activity>
, but if your application does not behave properly with hardware acceleration turned on globally, you can set it on <activity>
, and it means only that specific activity has the feature hardwareAccelerated
and not the whole app. So I think on your case, you can set it only on <application>
tag.
<application>
hardwareAccelerated
<activity>
<activity>
hardwareAccelerated
<application>
See more here.
https://developer.android.com/guide/topics/graphics/hardware-accel
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Better use it in lower resolution (view) and not for whole application.
– RonTLV
Aug 30 at 7:57