gpt4 book ai didi

java - token 语法错误,预期 ConstructorHeaderName 和 token 语法错误 "(",< 预期

转载 作者:太空狗 更新时间:2023-10-29 16:20:08 28 4
gpt4 key购买 nike

我收到两个错误,指出 token 上的语法错误,ConstructorHeaderName expected instead & token “(”上的语法错误,< expected

在线:

mTM.listen(callListener, PhoneStateListener.LISTEN_CALL_STATE);

...有什么建议吗?

public class DataCountService extends Service {
String text = "USR;1";
String ERROR = Constants.PREFS_NAME;
private Timer timer = new Timer();
private long period;
private long delay_interval;




EndCallListener callListener = new EndCallListener();
TelephonyManager mTM = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
mTM.listen(callListener, PhoneStateListener.LISTEN_CALL_STATE);

private class EndCallListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if(TelephonyManager.CALL_STATE_RINGING == state) {
// Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
}
if(TelephonyManager.CALL_STATE_OFFHOOK == state) {
//wait for phone to go offhook (probably set a boolean flag) so you know your app initiated the call.
// Log.i(LOG_TAG, "OFFHOOK");
}
if(TelephonyManager.CALL_STATE_IDLE == state) {
//when this state occurs, and your flag is set, restart your app
// Log.i(LOG_TAG, "IDLE");
}
}
}

最佳答案

线

mTM.listen(callListener, PhoneStateListener.LISTEN_CALL_STATE);

不包含在任何方法中。你应该把它放在 constructor 中(这看起来像你想要的)或常规方法。

关于java - token 语法错误,预期 ConstructorHeaderName 和 token 语法错误 "(",< 预期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17352905/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com