android getSystemService error with extends BroadcastReceiver -
i have 2 activities
public class mainactivity extends appcompatactivity {
.............. @override protected void oncreate(bundle savedinstancestate) { .............. .............. }
}
public class incomingsms extends broadcastreceiver{
public void onreceive(context context, intent intent){ .............. .............. }
public string getcelldata() {
telephonymanager telephonymanager = (telephonymanager) getsystemservice(context.telephony_service); gsmcelllocation celllocation = (gsmcelllocation) telephonymanager.getcelllocation();
.............. ..............
return somestring; }
i want return string getcelldata public void onreceive. there error on getsystemservice in getcelldata(). can do. thanks.
getsystemservice()
method on context
. broadcastreceiver
not inherit context
. however, passed context
onreceive()
. so, call getsystemservice()
on context
parameter.
Comments
Post a Comment