0

I'm writing a small android app which will fetch json file content through an URL and then parse and format it. But the content is not being fetched and my app showing "Unfortunately has stopped". Here is my code

Here is the log error

09-12 18:37:15.565: E/AndroidRuntime(2374): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.tatasky/my.tatasky.TataskyActivity}: android.os.NetworkOnMainThreadException

09-12 18:37:15.565: E/AndroidRuntime(2374): at my.tatasky.TataskyActivity.readJson(TataskyActivity.java:154)

The iOSDev
  • 5,188
  • 7
  • 42
  • 76
Bilbo Baggins
  • 3,584
  • 7
  • 38
  • 62

1 Answers1

0

In my apps i use gson. It is simple and fast:

https://sites.google.com/site/gson/gson-user-guide

Example: GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); gson.fromJson(json, MyObject[].class);

Try run it on an new thread.

jlccaires
  • 77
  • 1
  • 3