I have a Adobe Air application that intend to take a screenshot with Native Extension on Android device, but the java code returns a black image.
public FREObject call(FREContext context, FREObject[] params) {
View view = context.getActivity().getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap image = view.getDrawingCache();
}
I don't know much about Adobe Air. My java code runs exactly on Android Java Application, but returns black image on Adobe Air Android Application with Native Extension.
Is there any solution or any way to take a screenshot using Java in NativeExtension?
Thanks much!
Could be that you are not getting the correct view. Try this to get the topmost root view.
public FREObject call(FREContext context, FREObject[] params)
{
View view = findViewById(android.R.id.content).getRootView();
view.setDrawingCacheEnabled(true);
Bitmap image = view.getDrawingCache();
if(image == null)
{
System.out.println("Image returned was null!");
}
}
I also removed the buildDrawingCache() line; that can sometimes cause issues, and from what I've read it's not completely necessary.
Finally you'll want to check if the bitmap being returned is null. If so that could be why it's all black.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With