XML解析器触发警报AV [英] XML Parser triggers AV Alert
问题描述
我正在开发Android应用程序从一个在线的XML文件中读取当前的货币汇率,并通过W3C DOM解析它。该文件位于我的AWS S3存储。
I am developing an Android app which reads current currency exchange rates from an online XML file and parses it via w3c DOM. The file is located on my AWS S3 storage.
解析器工作正常,我得到的所有利率,因为我想他们,但我的防病毒应用程序(的的avast 的!)一直萎靡不振的我的应用程序为恶意软件(安卓代理-YI [TRJ ] )。当我评论了code了,我使用的方法只是返回真正
的AV保持安静,因此我把范围缩小到低于code。
The parser works fine and I get all rates as I want them but my Anti-Virus app (avast!) keeps flagging my app as Malware (Android:Agent-YI[Trj]). When I comment the code out and the method I use just returns true
the AV keeps quiet and thus I narrowed it down to the code below.
请问有人知道为什么AV不接受我的code?该应用程序的唯一权限是:
Does somebody know why the AV doesn't accept my code? The only permissions of the apps are:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
解析器code:
The parser code:
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文档,但遇到了同样的问题。
I also tried to use XmlPullParser
as recommended by the Android Documentation but ran into the same problem.
推荐答案
我想通了,为什么在AV不喜欢我的code。显然,XML解析没有造成问题,毕竟...
I figured out why the AV didn't like my code. Apparently the XML parsing did not cause the problem after all...
为了加载我用了一个的AsyncTask
并没有实现任何视觉反馈( ProgessDialog
),但该数据。仅此一点就足以让AV警报。
In order to load the data I used an AsyncTask
and did not implement any visual feedback (ProgessDialog
) yet. This alone was enough for the AV alert.
这篇关于XML解析器触发警报AV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!