gpt4 book ai didi

java - 'this' :method not applicable for the argument, 的一些问题也改进了格式

转载 作者:太空宇宙 更新时间:2023-11-04 15:05:12 25 4
gpt4 key购买 nike

你好

-A- 在应用程序设置中:

public class AppSettings {
...
public static String getLogFileName(Context context){
SharedPreferences pref = context.getSharedPreferences(GPSLOGGER_PREF_NAME, 0);
return pref.getString(LOG_FILE, "");
}

-B- 在主要 Activity 中:

  AppLog.logString("Version A 05 Service Started with interval " + interval + ", Logfile name: " + AppSettings.getLogFileName(this));

==> 工作正常

-C- 但在

public class SmsReceiver extends BroadcastReceiver

File kmlFile = new File(folder.getPath(),AppSettings.getLogFileName(this));

相同的指令“AppSettings.getLogFileName(this)”,但出现错误 (xxxx):

“该行有多个标记 - AppSettings 类型中的方法 getLogFileName(Context) 不适用于参数 (SmsReceiver) - 语法错误,插入“)”来完成VariableInitializer”

为什么?存在简单的解决方法吗?

编辑:添加“(”但还不够

“AppSettings 类型中的方法 getLogFileName(Context) 不适用于参数 (SmsReceiver)”

最佳答案

这一行缺少“)”?

File kmlFile = new File(folder.getPath(),AppSettings.getLogFileName(this); xxxx

尝试

File kmlFile = new File(folder.getPath(),AppSettings.getLogFileName(this));

关于java - 'this' :method not applicable for the argument, 的一些问题也改进了格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22096483/

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