Android Studio/JSON- Cannot resolve method "parseDouble"(java.lang.String)

I'm trying to get the temperature data from an API, and output it on my Android App.

I'm getting an errior saying "Cannot resolve method "parseDouble", what am I doing wrong?

2 answers

  • answered 2018-03-13 20:30 muminers

    Change:

    storeTemp = String.format("%.2f", main.getDouble("temp"))+ "°";
    

    to this

    storeTemp = String.format("%.2f", main2.getDouble("temp"))+ "°";
    

    In your code main is String and main2 is JSONObject that you persumably want to parse.

  • answered 2018-03-13 20:30 user2387962

    assign main as a double

      double main= Double.parseDouble(temp)