Android Question JavaObject : restarting from the ground...


Well-Known Member
Licensed User
Longtime User

Sorry as it will be a stupid question for many of you. I have decided to learn more seriously how to use JavaObject and choosed a really simple sample : getting the LoudSpeaker state (this because there is an example on And you know what ? I am already lost.

Well, if a good fellow around could help me understanding what I should do...

OK, here is the summary :
- seen here that I have to deal with AudioManager
- seen here that the class is ""
- on the same page that I will get a Boolean while calling isSpeakerPhoneOn()

Well, well. So I started really slowly trying to understand, dealing with some sample found here but with no luck.
I have seen that
Dim Jo As JavaObject
Produces no error. Classy :)

But it becomes difficult for me to understand the way to do. In fact, I wonder if I well understand the way to access the field (I am sorry if it is simple).
Dim Jo As JavaObject

If it is stupidly written, I do apologize, but you would have laughed :)

Thanks a lot


Licensed User
Longtime User
"Use Context.getSystemService(Context.AUDIO_SERVICE) to get an instance of this class."

and since I don't know how to do it using JavaObject:
Sub isSpeakerphoneOn As Boolean

    Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
    Return r.RunMethod("isSpeakerphoneOn")

End Sub

Upvote 0