Press on the image to return to the main documentation page.
Reflection
Written by Andrew Graham
This library contains a Reflector object that allows access to methods and fields of Android objects that are not exposed to the Basic4Android language. It does this by means of a facility called "Reflection" that uses meta-data for objects that is included in the application package and allows dynamic access to fields and methods at runtime.
GetActivity and GetActivityBA in this library only work for Basic4android 2.00 and higher. Use version 2.1 of this library for earlier versions of Basic4android.
The specifications for the primitive Java types recognised by this object are "java.lang.boolean", "java.lang.byte", "java.lang.char", "java.lang.short", "java.lang.int", "java.lang.long", "java.lang.float", and "java.lang.double" Note the lower-cased names. The single uppercase letter representation, as listed for arrays below, is also recognised.
The specifications for boxed primitive Java types which are true objects are "java.lang.Boolean", "java.lang.Byte", "java.lang.Char", "java.lang.Short", "java.lang.Int", "java.lang.Long", "java.lang.Float", and "java.lang.Double" Note the upper-cased names.
The specifications for arrays of primitive types is a number of square left brackets corresponding to the rank of the array followed by a single letter indicating the type. B represents the byte primitive type, S represents the short primitive type, I represents the int primitive type, J represents the long primitive type, F represents the float primitive type, D represents the double primitive type, C represents the char primitive type, Z represents the boolean primitive type. So a two dimension integer array is represented by "[[I".
The specifications for arrays of objects is similar but with the single letter replaced the letter "L", followed by the class name terminated by a semicolon ";". So a single dimension array of strings is represented by "[Ljava.lang.String;"
This is the object that does the reflection. In order to use this successfully you will need an understanding of the use of Java classes and their fields and methods.
'Full' (it is often lacking useful explanatory details) technical documentation is available on the Google Android website at http://developer.android.com.
Java is case sensitive and as used for Android does not support properties. Properties as implemented in Basic4Android are actually methods with lower case prefixes 'set' and 'get'. 'set' methods take a single parameter and return void, 'get' methods take no parameters and return the requested values. Any other method signatures are exposed by Basic4Android as normal methods. For example the Top property of a View is actually implemented in Java code as two methods, int getLeft() and void setLeft(int left). The Basic4Android compiler makes them look like a single property to the programmer.
Events:
Click(ViewTag As Object) LongClick(ViewTag As Object) As Boolean Focus(ViewTag As Object, Focus As Boolean) Key(ViewTag As Object, KeyCode As Int, KeyEvent As Object) As Boolean Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean