Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a funny bug cause hardware acceleration is working (sometimes). I've been searching for the answer to this for the last couple days. It’s documented in ICS but I have noticed it in one of my test phones a Samsung Galaxy S3 running 4.1.2 Most people suggest turning off hardware acceleration. I didn't want to do that cause hardware acceleration makes my animations so silky smooth. So what I found was if I override draw() try and catch the null pointer exception the hardware accelerated features work (most of the time) and enough for you to never notice they aren't working or throwing the exception. In my case I was doing a custom view and had some custom drawing to do. The simple check for null doesn’t work (canvas==null) which is why this bug is a pain. So what I did was this:</p> <pre><code> @Override public void draw(Canvas canvas) { try{ super.draw(canvas); mCanvas=canvas; }catch(java.lang.NullPointerException e){ Log.e("mytag","MyCustomView::draw():"+e); } if(mCanvas==null) return; ... </code></pre> <p>then silently try and caught any NPE on individual draw statements. First time I saw this bug I surrounded the entire draw() code in a try and catch. That worked for most phones but on the samsung s3 running 4.1.2 it was causing a flickering. So I used the above method and did silent try catch's on each call to someObject.draw(mCanvas) and that solved the problem entirely removing all flickering (disparity between hardware accelerated view cache and new canvas). Hope this helps! Way better than turning HWA off!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload