Pergunta

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.

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.

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"/>

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();
}

I also tried to use XmlPullParser as recommended by the Android Documentation but ran into the same problem.

Foi útil?

Solução

I figured out why the AV didn't like my code. Apparently the XML parsing did not cause the problem after all...

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top