我正在使用 getJSONFromUrl 这样的:
JSONParser jParser = new JSONParser();//Instantiate class
JSONObject json = jParser.getJSONFromUrl("http://tcc-teste.aws.af.cm/api/get/aluno/1");//using getJSNOFromUrl method
我在 logcat 上收到此错误:
08-28 22:46:06.560: E/AndroidRuntime(905): FATAL EXCEPTION: main
08-28 22:46:06.560: E/AndroidRuntime(905): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.br.edu.unifoa/com.example.br.edu.unifoa.MainActivity}: android.os.NetworkOnMainThreadException
08-28 22:46:06.560: E/AndroidRuntime(905): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
08-28 22:46:06.560: E/AndroidRuntime(905): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-28 22:46:06.560: E/AndroidRuntime(905): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-28 22:46:06.560: E/AndroidRuntime(905): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-28 22:46:06.560: E/AndroidRuntime(905): at android.os.Handler.dispatchMessage(Handler.java:99)
08-28 22:46:06.560: E/AndroidRuntime(905): at android.os.Looper.loop(Looper.java:137)
08-28 22:46:06.560: E/AndroidRuntime(905): at android.app.ActivityThread.main(ActivityThread.java:5103)