Rabu, 05 Desember 2012

Capture screen with getDrawingCache() repeatly

In the article "Create custom dialog with dynamic content, updated in onPrepareDialog()", it demonstrate how to capture screen with setDrawingCacheEnabled() and getDrawingCache() methods. Unfortunately, it cannot work as expected! The screen is captured in the first time only. After that, every time call getDrawingCache() return the same first screen.

To solve it call setDrawingCacheEnabled(false) and then setDrawingCacheEnabled(true) to re-load the cache bitmap.

Modify onClick() method of btnCaptureScreen's OnClickListener:
     btnCaptureScreen.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View arg0) {
screen.setDrawingCacheEnabled(false);
screen.setDrawingCacheEnabled(true);
bmScreen = screen.getDrawingCache();
showDialog(ID_SCREENDIALOG);
}});


Capture screen with getDrawingCache() repeatly

0 komentar:

Posting Komentar

Copyright © 2012 Codding News All Right Reserved