Reputation: 21
My Code:
public class location
{
private class MyPhoneStateListener extends PhoneStateListener
{
//Get the Signal strength from the provider, each time there is an update
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
}
/*some text*/
}
how can i invoke "onSignalStrengthsChanged" method from "location" class.
Upvotes: 1
Views: 139
Reputation: 21858
You need to create a new MyPhoneStateListener
instance and invoke the method on this instance.
For example:
public class location {
private class MyPhoneStateListener extends PhoneStateListener {
//Get the Signal strength from the provider, each time there is an update
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
}
/*some text*/
}
public void doSomething() {
PhoneStateListener listener = new MyPhoneStateListener();
listener.onSignalStrenghtsChanged(...);
}
}
Please notice that you can only create a MyPhoneStateListener
instance in the location
class because you defined the class private.
Also, notice that doSomething()
belongs to location
.
Upvotes: 4