Currently I am using view.getDrawingCache() now get drawing cache is deprecated
view.setDrawingCacheEnabled(true);
Bitmap bitamp = Bitmap.createBitmap(view.getDrawingCache())
view.setDrawingCacheEnabled(false);
view.getDrawingCache() is deprecated in Android API 28
Solution in java code is have getting error Callback
@RequiresApi(api = Build.VERSION_CODES.O)
public static void getBitmapFormView(View view, Activity activity, Callback callback) {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
int[] locations = new int[2];
view.getLocationInWindow(locations);
Rect rect = new Rect(locations[0], locations[1], locations[0] + view.getWidth(), locations[1] + view.getHeight());
PixelCopy.request(activity.getWindow(), rect, bitmap, copyResult -> {
if (copyResult == PixelCopy.SUCCESS) {
callback.onResult(bitmap);
}
}, new Handler(Looper.getMainLooper()));
}
Can not resolve Callback
- Activity
- Window
- Handler
which is supper class of callback ?