如何在Android中导入PreciseCallState.java?

时间:2015-08-06 09:02:49

标签: android

我想使用'PreciseCallState.java'来监听外出呼叫的状态。

public class OutCallLogger extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getIntExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, -2)) {
        case PreciseCallState.PRECISE_CALL_STATE_IDLE:
            //Log.d(this.LOG_TAG, "IDLE");
            Toast.makeText(context,"hello",Toast.LENGTH_LONG).show();
            break;
        case PreciseCallState.PRECISE_CALL_STATE_DIALING:
            //Log.d(this.LOG_TAG, "DIALING");
            break;
        case PreciseCallState.PRECISE_CALL_STATE_ALERTING:
            //Log.d(this.LOG_TAG, "ALERTING");
            break;
        case PreciseCallState.PRECISE_CALL_STATE_ACTIVE:
            //Log.d(this.LOG_TAG, "ACTIVE");
            break;
    }
}

我还将其添加到AndroidManifest.xml。

<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
<receiver android:name=".listener.OutCallLogger">
    <intent-filter>
        <action android:name="android.intent.action.PRECISE_CALL_STATE" />
    </intent-filter>
</receiver>

但AndroidStudio说“无法解析符号'PreciseCallState'”, 虽然我知道PreciseCallState.java存在于sdk文件夹/ android / telephony中。

0 个答案:

没有答案