0

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??

신승빈
  • 347
  • 3
  • 10

1 Answers1

0

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.

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
  • Thanks, I miss that. But It didn't work if I remove all of that code at OnDraw() and if I write down 'Log.v("temp", String.valueOf(canvas.isHardwareAccelerated()));' It return false. – 신승빈 Nov 10 '17 at 05:54
  • Update your question with what you've done, as it isn't clear from your comment what you changed with your code and what results you are getting now. – Morrison Chang Nov 10 '17 at 06:27
  • OK. Question is updated. I changed only onDraw method at AccelTestView class. As you can see when I try that code and when I see logcat, it was false. – 신승빈 Nov 10 '17 at 07:09
  • Apologies - just realized you are testing on AVD. Check the emulated graphics settings for each emulator: https://developer.android.com/studio/run/emulator-acceleration.html#avd-gpu Also note the command line modes available in the section below it. Your particular configuration (PC/graphics card) may be hitting one of the edge cases. For completeness you should update your question with what CPU and version of emulator (HAXM or ARM emulation). – Morrison Chang Nov 10 '17 at 07:32
  • Thanks a lot of your help and feel sorry about that my answer is slow. I approach that 'verify configuration' and I found that emulated perfomance is setted by software. So I changed that setting and check it again. But the setting hold by software. It didn't change. And I just give up about this problem. Just I change minimum API Level. I'm really appreciate about your help. – 신승빈 Nov 12 '17 at 23:56