Android Question Reading Phone cell info when screen is off.

leongcc

Member
Licensed User
Longtime User
I am reading phone cell info. using the following codes.
It works only when the screen is on.
If the screen is off, the data returned will remain unchanged although I have already moved to another cell coverage.
I just want to ask if it still impossible to read CID,LAC when the phone screen is off.


B4X:
ReflectorObj.Target = ReflectorObj.GetContext
ReflectorObj.Target = ReflectorObj.RunMethod2("getSystemService", "phone", "java.lang.String")   
OperatorName = ReflectorObj.RunMethod("getNetworkOperatorName")   
MccMnc = ReflectorObj.RunMethod("getNetworkOperator")
       
ReflectorObj.Target = ReflectorObj.GetContext
ReflectorObj.Target = ReflectorObj.RunMethod2("getSystemService", "phone", "java.lang.String")
ReflectorObj.Target = ReflectorObj.RunMethod("getCellLocation") 
Cid = ReflectorObj.RunMethod("getCid") 
Lac = ReflectorObj.RunMethod("getLac")
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Are you using this code in a service and are you sure it is not killed after screen is off .
You might also want to check PhoneEvents from Phone library
It has ConnectivityChanged event I did not test it but it seems to be called when network is changed
 
Upvote 0

leongcc

Member
Licensed User
Longtime User
Thanks for responding.
Yes, the codes run in Service and the happenings are continuously logged into a file.
So I am sure the Service it not killed and very sure the cell info. are not updated.

I will try the PhoneEvents you suggested but I doubt ConnectivityChanged will be fired.
 
Upvote 0

leongcc

Member
Licensed User
Longtime User
Just tested. ConnectivityChanged does not report any cellular info regardless screen is on or off.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…