android - getDrawingCache return null when run monkey -


i have follow code screenshot

    view screen = getwindow().getdecorview();     screen.setdrawingcacheenabled(true);     screen.setdrawingcachequality(view.drawing_cache_quality_high);     screen.builddrawingcache();      bitmap bitmap = screen.getdrawingcache(); 

the code in onoptionsitemselected in ui thread.

it runs fine when test manually. however, when run app monkey, bitmap nulli not sure if null in monkey mode or since monkey's randomness.

any ideas why monkey behave differently? not want blindly add null pointer checker in later code.

thanks

you should use builddrawingcache(true) because builddrawingcache() same builddrawingcache(false).make sure copy bitmap 1 before using getdrawingcache() below.

bitmap bt=bitmap.createbitmap(screen.getdrawingcache()); 

because copy our bitmap before recycle() if call setdrawingcacheenabled(false).


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -