Android Question [SOLVED] getCallState() Via Reflection

ipika july

Member
Licensed User
Longtime User
Hi,
This is my first post.
I was trying to make an application which is active while we are on call.

I found phone state listener library which helped me.
But in few application broadcast wasn't there while call was disconnected.

So i found a method getCallState() from http://developer.android.com/reference/android/telephony/TelephonyManager.html#getCallState() which i want to use in B4A.

i tried reflection library but code throws nullpointerexception erro

B4X:
Dim r As Reflector
    r.Target = r.GetContext
    Dim TelephonyManager As Object
    TelephonyManager = r.RunMethod2("getSystemService", "telephony", "java.lang.String")
    r.Target = TelephonyManager
    Log(r.runPublicMethod("getCallState",null,null))
 

ipika july

Member
Licensed User
Longtime User
As i told i have used broadcast receiver but there exist some issue.
& i cannot find samples/tutorial of reflection library so i cannot do more.

i updated code but still it throws error

B4X:
Dim r As Reflector
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "telephony", "java.lang.String")
    Log(r.RunMethod("getCallState"))
 
Last edited:
Upvote 0
Top