Dodaj PhoneStateListener

Próbuję skonfigurowaćPhoneStateListener ale dostajęPhoneCallListener cannot be resolved to a type.

public class ButtonView extends FrameLayout  {

     PhoneCallListener phoneListener = new PhoneCallListener();
     TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
     telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
}

W innym przykładzie znalazłem napisane w ten sposób i działa

public class MainActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {

        // add PhoneStateListener
        PhoneCallListener phoneListener = new PhoneCallListener();
        TelephonyManager telephonyManager = (TelephonyManager) this
            .getSystemService(Context.TELEPHONY_SERVICE);
        telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
}

Co powinienem zmienić w swoim kodzie, aby działał?

questionAnswers(1)

yourAnswerToTheQuestion