Android Question ScreenShot Not Working

rodmcm

Active Member
Licensed User
I have searched this site for the options for screen shot and tried a few options without success. I see the file in the File.DirInternal and in Gallery, however in Gallery it is a greyed out rectangle.

The second option ( disabled in the attached program) gives the same result

I am using a Levono tablet with Android 6.0.1


Any suggestions please..
 

Attachments

  • ScreenShotPlay.zip
    12.9 KB · Views: 151

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I have searched this site for the options for screen shot and tried a few options without success. I see the file in the File.DirInternal and in Gallery, however in Gallery it is a greyed out rectangle.

The second option ( disabled in the attached program) gives the same result

I am using a Levono tablet with Android 6.0.1


Any suggestions please..

This works fine for me.
Ignore the dialog bit.

B4X:
Sub SaveScreenShot
 
 Dim strDefault As String
 
 If iCurrentPanelType = ePanelType.SQLEdit Then
  If lblOpenedSQL.Text.Length > 0 Then
   strDefault = lblOpenedSQL.Text
  End If
 End If
 
 Dim rs As ResumableSub = Dialog.Show(Activity, Array As Object("OK", "Cancel"), _
        "Save screenshot", strDefault, _
        "Type in the File name." & CRLF & CRLF & "Don't put in the file extension (will be .png)", _
        0, False, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, Null, False)
 Wait For (rs) Complete (strFile As String)
 If  strFile = "Cancel" Then Return
 
 Dim bmp As Bitmap
 
 bmp = TakeScreenshot
    
 SaveBitmap(bmp, strFile & ".png")

End Sub

Sub SaveBitmap(bmp As Bitmap, strFile As String)
 
 Dim Out As OutputStream
 
 Out = File.OpenOutput(Starter.strAppDir, strFile, False)
 bmp.WriteToStream(Out, 100, "PNG")
 Out.Close
 
End Sub

Sub TakeScreenshot As Bitmap
 
 Dim jo As JavaObject
 
 jo.InitializeContext
 
 Dim decor As JavaObject = jo.RunMethodJO("getWindow", Null).RunMethod("getDecorView", Null)
 Dim decorChild As JavaObject = decor.RunMethod("getChildAt", Array(0))
 
 decorChild.RunMethod("setDrawingCacheEnabled", Array(True))
 decorChild.RunMethod("buildDrawingCache", Null)
 
 Dim bmp As Bitmap = decorChild.RunMethod("getDrawingCache", Array(True))
 
 bmp.Initialize3(bmp)
 decorChild.RunMethod("setDrawingCacheEnabled", Array(False))
 Return bmp
 
End Sub

RBS
 
Upvote 0
Top