Android Question Help with Reflection

Hello,
I am trying to learn a bit more about the libraries before purchasing this great software! I understand most of them in theory (without programming because I dont actually have them) except for the reflection library. I was trying to figure out how I would use the clipboard library (http://developer.android.com/reference/android/text/ClipboardManager.html) to put some text in the clipboard as an example for practice but everything I write does not seem correct.
This is what I have written so far (but have not tested):

Dim r As Reflector
r.target=r.RunMethod("java.text.clipboardmanager")
r.RunMethod2("settext","hello","java.lang.object")

with hello being the text added to the clipboard but it seems incorrect with the java.text.clipboardmanager compared to the other examples of the reflection library I have seen where there is no dots in there. Could somebody please point me in the right direction or give me the code for the clipboard as a reference.

Help would be appreciated to help me understand more about this library!

All the best and happy holidays,
Joseph
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Hello,
I am trying to learn a bit more about the libraries before purchasing this great software! I understand most of them in theory (without programming because I dont actually have them) except for the reflection library. I was trying to figure out how I would use the clipboard library (http://developer.android.com/reference/android/text/ClipboardManager.html) to put some text in the clipboard as an example for practice but everything I write does not seem correct.
This is what I have written so far (but have not tested):

Dim r As Reflector
r.target=r.RunMethod("java.text.clipboardmanager")
r.RunMethod2("settext","hello","java.lang.object")

with hello being the text added to the clipboard but it seems incorrect with the java.text.clipboardmanager compared to the other examples of the reflection library I have seen where there is no dots in there. Could somebody please point me in the right direction or give me the code for the clipboard as a reference.

Help would be appreciated to help me understand more about this library!

All the best and happy holidays,
Joseph



You can use this library for clipboard.

About Reflection... I try to avoid it as much as possible, because I know It just a little.
As far as I know, public objects are accessible, maybe static classes. For the moment I will not lose my head. The beauty of B4A is just that (at least until there are libraries / classes in B4A)
 
Upvote 0
Thanks for your reply and pointing out the library. I just wanted to understand how to use the reflection library with the clipboard manager as an example. If anyone has any advice or code examples as to how I would go about doing that, I would be grateful.

Regards,
Joseph Zed
 
Upvote 0
Yes, I understand! I just wanted to learn a bit more about this library using the clipboard manager as a example for myself as I didnt notice the library has already been made.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Yes, I understand! I just wanted to learn a bit more about this library using the clipboard manager as a example for myself as I didnt notice the library has already been made.


Many of us need to learn the Reflection. I think I've asked this question, probably in a Wish .. a tutorial well done; but I know, this is complex, requires knowledge of Android, as well as Java.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User

I had seen that thread. From there, before we delve into it all, I went on "Reflection Documentation."

But as soon as I found strange things, I gave up.

In the documentation, it seems that the Reflector object has events, such as Click!

Moreover, it is difficult to understand if you can work only on static classes / methods, on Android, Java or B4A or on any of them.

At this time I do not remember (too many things in the oven!) but I know I tried to get something, even following all the documentation of Android and I always got some error (incorrect references to objects, usually).

Although I know enough classes, inheritance, polymorphism, etc. I find that it is complicated (of course, the language does not help me!).

Probably the document is not how I would like it or I have spend short time to it.

Anyway, many thanks for the link.

P.S. Moreover, it is not the task of this forum teach programming in Java and Android API, indeed, is to circumvent its difficulties (I love your wrappers ;))
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
When you get back to looking at reflection, if you have a problem with it or any of the examples on the forum, just ask a specific question. You will get an answer. It is more complex than using the built in functions of B4a as you are dealing directly with the API's. But persevere and you will reap the rewards.

Trial and error is the key, until you get used to it.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
When you get back to looking at reflection, if you have a problem with it or any of the examples on the forum, just ask a specific question. You will get an answer. It is more complex than using the built in functions of B4a as you are dealing directly with the API's. But persevere and you will reap the rewards.

Trial and error is the key, until you get used to it.

:)
 
Upvote 0
Top