Now it's not the devs fault, the one in the Android SDK is too slow as well
At some point, you must:
Then just call it via:
At some point, you must:
B4X:
dim bg as canvas
bg.Initialize(activity)
B4X:
Sub UniqueFilename(Dir As String, Filename As String, Append As String ) as string
Dim temp As Int ,Lindex As Int, Lpart As String , Rpart As String
If Append.Length=0 Then Append=" (#)"
If File.Exists(Dir, Filename) Then
Lindex= filename.LastIndexOf(".")
If Lindex=-1 Then
Lpart=filename
Else
lpart = filename.SubString2(0,lindex)
Rpart = filename.SubString(lindex)
End If
temp=1
Do Until Not( File.Exists(dir, lpart & Append.Replace("#", temp) & rpart))
temp=temp+1
Loop
Return lpart & Append.Replace("#", temp) & rpart
Else
Return filename
End If
End Sub
Sub SaveScreenshot(BG As Canvas, Dir As String, FilenamePNG As String )As String
Dim Out As OutputStream
FilenamePNG=UniqueFilename(dir, FilenamePNG, "")
Out = File.OpenOutput(Dir, FilenamePNG, False)
BG.Bitmap.WriteToStream(out, 100, "PNG")
Out.Close
Return Dir & "/" & FilenamePNG
End Sub
Then just call it via:
B4X:
ToastMessageShow( SaveScreenshot(BG, File.DirRootExternal, "Screenshot.PNG") ,True)
Last edited: