* Registers a listener object to receive notification of changes * in specified telephony states. * To register a listener, pass a {@link PhoneStateListener} * and specify at least one telephony state of interest in * the events argument. * At registration, and when a specified telephony state * changes, the telephony manager invokes the appropriate * callback method on the listener object and passes the * current (udpated) values. * To unregister a listener, pass the listener object and set the * events argument to {@link PhoneStateListener#LISTEN_NONE LISTEN_NONE} (0) telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); psListener = new PhoneStatusListener(); telManager.listen(psListener, PhoneStateListener.LISTEN_CALL_STATE); //监听 telManager.listen(psListener, PhoneStateListener.LISTEN_NONE); //取消监听
生活不应该只有工作,Stay还有更多编程与感悟希望和你分享。如果我的磁场吸引到你,请关注微信:stay4it,QQ:104816053。