Android Question Take a Screenshot full activity

Discussion in 'Android Questions' started by klingon467, Jun 9, 2015.

  1. klingon467

    klingon467 Member Licensed User

    Hi at all,
    i see this old topic: http://www.b4x.com/android/forum/threads/take-screenshot-in-b4a-version-2-0.18820/
    and i trying to create a android app with this function but i using service module and i want capture other activity on phone
    i have modify the function so:
    Code:
    Sub TakeScreenshot
        
    Log("TakeScreenshot activated")
           
    ' Take a screenshot.
         Dim c As Canvas
         
    Dim Obj1, Obj2 As Reflector
         
    Dim now As Long
         
    Dim dt As String
          
    Try
         
           
    DateTime.DateFormat = "yyMMddHHmmss"
           now = 
    DateTime.now
           dt = 
    DateTime.date(now) ' e.g.: "110812150355" is Aug.12, 2011, 3:03:55 p.m.
           Obj1.Target = Obj1.GetActivityBA
           Obj1.Target = Obj1.GetField(
    "vg")
         
           c.Initialize2(bmp)
           
    Dim args(1As Object
           
    Dim types(1As String
           Obj2.Target = c
           Obj2.Target = Obj2.GetField(
    "canvas")
           args(
    0) = Obj2.Target
           types(
    0) = "android.graphics.Canvas"
           Obj1.RunMethod4(
    "draw", args, types)
           
    Dim Out As OutputStream
           Out = 
    File.OpenOutput(File.DirRootExternal, dt & ".png"False)
           bmp.WriteToStream(Out, 
    100"PNG")
           Out.close
           
    Catch
           
    Log(LastException.Message)
           
    End Try
    End Sub
    Code:
    Sub Service_Create
    bmp.InitializeMutable(
    480dip350dip)

    .....
    end sub
    Code:
    Sub Process_Globals
      
    Dim bmp As Bitmap
    End sub
    for using i call TakeScreenshot function but i recived a error:
    TakeScreenshot activated
    java.lang.NullPointerException

    thanks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    No. It is not possible in Android to take screenshots of other applications. The only way to do it is when the device is connected in USB debug mode.
     
    thedesolatesoul and klingon467 like this.
Loading...