好吧,我正在使用猎物源代码来开发我自己的防盗应用程序。根据 git ,我从那里得到了 5 个文件。但我正在研究一个大师,我认为这是正确的一个。
当我将它上传到 Eclipse 时,我收到 100 个错误,其中一个仍然保留在 FileConfigReader.java中,错误是:
说明:config无法解析或不是字段
资源:FileConfigReader.java
路径:/LoginActivity/src/com/prey
位置:第 25 行
类型:Java 问题
出现错误的行:
InputStream = ctx.getResources().openRawResource(R.raw.config);
该文件的代码:
/*******************************************************************************
* Created by Carlos Yaconi
* Copyright 2012 Fork Ltd. All rights reserved.
* License: GPLv3
* Full license at "/LICENSE"
******************************************************************************/
package com.prey;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import android.content.Context;
import android.content.res.Resources.NotFoundException;
public class FileConfigReader {
private static FileConfigReader _instance = null;
Properties properties;
private FileConfigReader(Context ctx) {
try {
PreyLogger.d("Loading config properties from file...");
properties = new Properties();
InputStream is = ctx.getResources().openRawResource(R.raw.config);
properties.load(is);
is.close();
PreyLogger.d("Config: "+properties);
} catch (NotFoundException e) {
PreyLogger.e("Config file wasn't found", e);
} catch (IOException e) {
PreyLogger.e("Couldn't read config file", e);
}
}
public static FileConfigReader getInstance(Context ctx){
if (_instance == null)
_instance = new FileConfigReader(ctx);
return _instance;
}
public String getAgreementId(){
return properties.getProperty("agreement-id");
}
public String getGcmId(){
return properties.getProperty("gcm-id");
}
public String getGcmIdPrefix(){
return properties.getProperty("gcm-id-prefix");
}
public String getc2dmAction(){
return properties.getProperty("c2dm-action");
}
public String getc2dmMessageSync(){
return properties.getProperty("c2dm-message-sync");
}
public String getPreyDomain(){
return properties.getProperty("prey-domain");
}
public String getPreySubdomain(){
return properties.getProperty("prey-subdomain");
}
public String getPreyUiSubdomain(){
return properties.getProperty("prey-ui-subdomain");
}
public String getPreyMinorVersion(){
return properties.getProperty("prey-minor-version");
}
public boolean isAskForPassword() {
return Boolean.parseBoolean(properties.getProperty("ask-for-password"));
}
public boolean isLogEnabled() {
return Boolean.parseBoolean(properties.getProperty("log-enabled"));
}
public String getAnalyticsUA() {
return properties.getProperty("analytics-ua");
}
}
任何帮助将不胜感激。:)