我試圖設置PhoneStateListener,但我收到「PhoneCallListener無法解析爲某種類型」。添加PhoneStateListener
public class ButtonView extends FrameLayout {
PhoneCallListener phoneListener = new PhoneCallListener();
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
}
在另一個例子中,我發現它這樣寫的,它的工作
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);
}
,使其工作在我的代碼,我應該怎麼改? 感謝您的幫助
http://stackoverflow.com/questions/ 5345470/onclicklistener-無法解析到一個類型的蝕 – Omarj