Android Question Reflector vs JavaObject

Caps64

Member
I am learning B4A and I would like to understand more about Reflector and JavaObject.
As far as I understand so far, the following code using Reflector:
B4X:
Sub VideoFrameAtR(dir As String, f As String, ms As Long) As Bitmap   
    Dim r As Reflector
    Dim obj As Object
    Dim bmp As Bitmap    
    obj = r.CreateObject("android.media.MediaMetadataRetriever")
    r.Target = obj
    r.RunMethod2("setDataSource", File.Combine(dir, f), "java.lang.String")
    bmp = r.RunMethod3("getFrameAtTime", ms*1000, "java.lang.long", 3, "java.lang.int")    ' 3=OPTION_CLOSEST
    Return bmp
End Sub
should be the same of the following that uses JavaObject (that I find more easy):
B4X:
Sub VideoFrameAt(dir As String, f As String, ms As Long) As Bitmap   
    Dim job As JavaObject
    Dim bmp As Bitmap
    job.InitializeNewInstance("android.media.MediaMetadataRetriever",Null)
    job.RunMethod("setDataSource", Array(File.Combine(dir, f)))   
    bmp = job.RunMethod("getFrameAtTime", Array(ms*1000, 3))
    Return bmp
End Sub

Then what is the difference between Reflector and JavaObject, if any ?
What code runs faster ?
 

OliverA

Expert
Licensed User
Longtime User
No difference.
Was I then under the false understanding that the Reflector class allowed access to private methods/objects/data whereas JavaObject class only allowed access to public information?
 
Upvote 0
Top