bewantbe / audio-analyzer-for-android

A fork of audio-analyzer-for-android in Google code, with a lot of enhancement.
Apache License 2.0
284 stars 116 forks source link

Spam(Spectrogram) Not working on Android Oreo. #19

Closed SteveLars closed 6 years ago

SteveLars commented 6 years ago

For some reason the display of the spectrogram is not displaying the graphical data in an emulator and Google Pixel device running Android Oreo. All the data in that mode is working, just for some reason the rendering of the spectrogram is not happening. I tried to poke around the code, and I could not figure out what the issue is.

@bewantbe

bewantbe commented 6 years ago

Got reports from email also recently.

The problem in is the deprecated function drawBitmap function:

void drawBitmap (int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)

Seems I need to switch to the Bitmap version of drawBitmap.

SteveLars commented 6 years ago

In one app I still use drawBitmap in Android 8.0 and everything renders properly, so perhaps that is not the problem. My drawBitmap is significantly simpler than yours, so I could be wrong. Thank you for looking into this.

bewantbe commented 6 years ago

This bug should be fixed in the commit 9960a68. And a new version tagged by v1.6.9 will be pushed to playstore, if it is all good (Could you help me test it at your convenience? @SteveLars ).

The problem is in Android 8.0, 8.1 the Canvas.drawBitmap(int[]...hasAlpha..) function will use the alpha channel even when hasAlpha==false. So always set alpha=0xff fixes it.

SteveLars commented 6 years ago

It works. I am very glad to hear you fixed this so quickly. @bewantbe