在方法“ onCreate”中调用扩展PhoneStateListener的类

时间:2018-10-18 10:11:51

标签: android

我有一个手电筒应用程序,想在方法“ onCreate”中调用扩展PhoneStateListener的类

这里是我要呼叫的类..以便在来电时点亮闪光灯

我该怎么做?


 private class CallStateListener extends PhoneStateListener {
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            switch (state) {
                case TelephonyManager.CALL_STATE_RINGING:
                    // called when someone is ringing to this phone
                    getCamera();
                    turnOnFlash();

                    break;
            }
        }
    }

0 个答案:

没有答案