i need to call method from several classes, but i don’t know how to get the right context
the holding class:
public class SharedData {
......
......
public static void stop_ring(Context context){
Uri lcurUri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION);
Ringtone ring = RingtoneManager.getRingtone(context, lcurUri);
ring.stop();
}
how can i call it from activity class, and how can i call it from PhoneStateListener class.
Activity extends Context so you can call it like so:
For a listener you will have to put Context in the constructor and save it as a property. Then call: