Search code examples
androidhardware-accelerationandroid-api-levels

I can't hardware acceleration at api level 15


I'm testing a simple hardware accelerated at android.

I found this code on the internet so I want to test this. And it works when I test this code at API Level 26, but when I test this at API Level 15 which is same avd, it didn't work.

Here is my Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shin.myapplication">

<application
    android:hardwareAccelerated="true"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

And MainActivity.

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.acceltest1);
    AccelTestView vw = new AccelTestView(this);
    setContentView(vw);
}

And this is AccelTestView code

public class AccelTestView extends View {

public AccelTestView(Context context) {
    super(context);
}

public void onDraw(Canvas canvas) {
    Log.v("temp", String.valueOf(canvas.isHardwareAccelerated()));
    invalidate();
}

Here is API Level 15 Image

And here is API Level 26 Image

Those two images are same code and same avd which is Nexus 5x.

Why this happen??


Solution

  • Please read:

    https://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported

    From the chart it shows that hardware acceleration for setAntiAlias isn't available until API 16 for lines and API 18 for text.