B4A Library Reflection library

agraham

Expert
Licensed User
There will be lots to come in future versions of Basic4Android as Erel adds more of Androids capabilities. In the mean time there will be things that would be nice to have but are not actually implemented. This library will help to solve at least some of those requirements.

This is the Android equivalent of the Basic4ppc Door library that turned out to be so useful. There is a demo for the library that adds onFocus and onTouch events to views that don't implement them, accesses objects fields and runs methods.

A separate demo shows how to "Linkify" text so that URLs in the text become active hyperlinks.

EDIT:- Version 1.1 posted. See post #17 for details.

EDIT:- Version 1.2 posted. Bug fix. See post#19 for details.

EDIT:- Version 1.3 posted. See post#20 for details.

EDIT:- Version 1.4 posted. See post#21 for details.

EDIT:- Version 1.5 posted. See post #25 for details.

EDIT:- Version 1.6 posted. See post #31 for details.

EDIT:- Version 1.7 posted. See post #32 for details.

EDIT:- Version 1.8 posted. See post #33 for details.

EDIT:- Version 1.9 posted. See post #48 for details.

EDIT:- Version 2.0 posted. See post #51 for details.

EDIT:- Version 2.1 posted. See post #53 for details.

EDIT:- Version 2.2 posted for Basic4android 2.0 or later. Version 2.1 remains for earlier versions. See post #57 for details.

EDIT:- Informatix has produced Version 2.3 in post #317

EDIT:- Version 2.4 posted. See post #91 for details.
 

Attachments

Last edited:

BPak

Active Member
Licensed User
Andrew I get this message when clicking on the file link.

BPak, you do not have permission to access this page. This could be due to one of several reasons:
 

Cor

Active Member
Licensed User
where you already a licensed user then before it was officialy released?

grCor
 

agraham

Expert
Licensed User
Yes. I tested the Basic4Android setup and the registered user only forum access for Erel yesterday. I am having no trouble downloading either Basic4ppc libraries or the Android libraries that I posted so maybe there is some permission problem on the forum, although why that would give corrupted downloads I can't imagine.
 

Cor

Active Member
Licensed User
When I download it gives me the following file:

6625d1291656678-reflection-library-reflection1.0.zip

But it seems that i must first order it ;-)

that could not take long from now....

grCor
 

susu

Well-Known Member
Licensed User
Thanks Agraham for Linkify demo. Could you please explain the code below?

Dim args(2) As Object
Dim types(2) As String
args(0) = Label1
types(0) = "android.widget.TextView"
args(1) = 1
types(1) = "java.lang.int"
Obj1.RunMethod4("addLinks", args, types)
I read about Linkify class (Linkify | Android Developers) but can't guess which public method you used.

One more thing, can you write another demo using Contacts class to pick phone number? (ContactsContract.Contacts | Android Developers)

Thank you so much.
 

agraham

Expert
Licensed User
but can't guess which public method you used.
addLinks(TextView text, int mask)

One more thing, can you write another demo using Contacts class to pick phone number?
I'm afraid not. This library is for manipulating objects that already exist in Basic4android not for programming things that Basic4android presently cannot do.
 

moster67

Expert
Licensed User
Agraham,

I have read the help-file as to the reflection-library but still I am bit unsure what I can use it for. Would you be able to give some examples what can be done and what can't be done (I'm not asking for code-examples) so one can get an idea.

For instance, I got hold of this java-code which tells a particular video-viewer (called vPlayer) to open an URL. I noted that it uses "intents" which can also be found in PhoneIntents in the Core-library using the method OpenBrowser.

B4X:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setPackage("me.abitno.vplayer"); i.setDataAndType(Uri.parse(openUrl), "video/*");
startActivity(i);
I am bit confused :sign0104:
 

agraham

Expert
Licensed User
It is used in an identical way to the Door library in Basic4ppc. Java and C# are very similar languages and reflection works in much the same way in both.

I'm not going to get into descriptions of how to use it. You need to know something about Java or C# to use it and if you know enough then how to use it will be pretty obvious.

It is not intended to implement features of Android that are not presently implemented in Basic4android. People need to patient, there is loads more functionality to be implemented in both future versions of Basic4android and in custom libraries but that will take time.
 

m0narX

Member
Licensed User
agraham, can i use this library to call
android.os.RecoverySystem.installPackage(Context context, File packageFile)?
And how?
 

agraham

Expert
Licensed User
Version 1.1 posted has had an obvious omission corrected. You can now run static class methods using a new method - RunStaticMethod. An example of using it to encode and decode a URI is provided
 

moster67

Expert
Licensed User
Perfect - the URI-encoding was just what I needed (no more need for replacing characters or filling in blank spaces in my URI-strings)

Thank you.
 

agraham

Expert
Licensed User
In version 1.3, now posted, the RunMethodX methods now throw the first Exception they trap. Previously, if an Exception caused another Exception and so on the last Exception trapped was returned. This made establishing the real reason for failure difficult - as I have just spent a couple of hours finding out the hard way! :(
 
Top