1
我正在開發一個Android應用程序,它從在線XML文件讀取當前貨幣匯率並通過w3c DOM解析它。該文件位於我的AWS S3存儲上。XML解析器觸發AV警報
解析器工作正常,我得到的所有速率我想他們,但我的防病毒應用程序(的avast!)標記保持我的應用程序爲惡意軟件(安卓代理-YI [TRJ])。當我將代碼註釋掉並且我使用的方法僅返回true
時,AV保持安靜,因此我將其縮小到下面的代碼。
有人知道AV爲什麼不接受我的代碼嗎?該應用程序的唯一權限是:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
解析器代碼:
public static boolean fetchCurrencyRates(String in)
{
boolean success = true;
HashMap<String, Double> onlineRates = new HashMap<String, Double>();
try
{
Document xmlRates = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
xmlRates.getDocumentElement().normalize();
NodeList xmlItems = xmlRates.getElementsByTagName("item");
for(int i = 0; i < xmlItems.getLength(); i++)
{
Node n = xmlItems.item(i);
if(n != null && n.getNodeType() == Node.ELEMENT_NODE)
{
Element currency = (Element) n;
String code = currency.getElementsByTagName("title").item(0)
.getTextContent()
.substring(0, 3);
String rate = currency.getElementsByTagName("description").item(0)
.getTextContent()
.split(" ")[3];
Log.i("DEV", code + ": " + rate);
onlineRates.put(code, Double.parseDouble(rate.replaceAll(",", "")));
}
}
}
catch(Exception e)
{
Log.e("DEV", e.getMessage();
success = false;
}
return success && !onlineRates.isEmpty();
}
我還試圖用XmlPullParser
所推薦的Android文檔,但遇到了同樣的問題。