0

I'm trying to populate ListView with data from MySQL. I used this tutorial.

Here I want to get data only when rating is equal to 3. I try this, but it doesn't work. I don't really understand how JSON works. Probably I can't get the same value from the same column. Then, I try creating a new column with the same values like rating, but it doesn't work too. The emulator started, but then app crashed.

First attempt

try {
    // convert json string to json array
    JSONArray aJson = new JSONArray(sJson);
    // create apps list
    String rating = "3";
    List<Application> apps = new ArrayList<Application>();

    for(int i=0; i<aJson.length(); i++) {
        JSONObject json = aJson.getJSONObject(i);
        Application app = new Application();
        String rating_of_app = json.getString("rating");
        if ((rating_of_app).equals(rating)) {
            app.setTitle(json.getString("app_title"));
            app.setTotalDl(Long.parseLong(json.getString("total_dl")));
            app.setRating(Integer.parseInt(json.getString("rating")));  
            app.setIcon(json.getString("icon"));}

            // add the app to apps list
            apps.add(app);
        }

Second attempt with new column

try {
    // convert json string to json array
    JSONArray aJson = new JSONArray(sJson);
    // create apps list
    String rating = "3";
    List<Application> apps = new ArrayList<Application>();

    for(int i=0; i<aJson.length(); i++) {
        JSONObject json = aJson.getJSONObject(i);
        Application app = new Application();
        String rating_of_app = json.getString("rating_for_if");
        if ((rating_of_app).equals(rating)) {
            app.setTitle(json.getString("app_title"));
            app.setTotalDl(Long.parseLong(json.getString("total_dl")));
            app.setRating(Integer.parseInt(json.getString("rating")));  
            app.setIcon(json.getString("icon"));}
            // add the app to apps list
            apps.add(app);
        }      

When I don´t put there if statement it works great but it is useless for me.

Here it is for the first Attempt:

09-10 05:15:44.970: D/dalvikvm(837): GC_FOR_ALLOC freed 50K, 5% free 2948K/3084K, paused 277ms, total 278ms
09-10 05:15:44.970: I/dalvikvm-heap(837): Grow heap (frag case) to 3.565MB for 635812-byte allocation
09-10 05:15:45.150: D/dalvikvm(837): GC_FOR_ALLOC freed 2K, 4% free 3566K/3708K, paused 96ms, total 164ms
09-10 05:15:46.670: I/Choreographer(837): Skipped 67 frames!  The application may be doing too much work on its main thread.
09-10 05:15:47.580: I/Choreographer(837): Skipped 159 frames!  The application may be doing too much work on its main thread.
09-10 05:15:47.890: D/gralloc_goldfish(837): Emulator without GPU emulation detected.
09-10 05:15:48.160: I/Choreographer(837): Skipped 52 frames!  The application may be doing too much work on its main thread.
09-10 05:15:48.460: I/Choreographer(837): Skipped 48 frames!  The application may be doing too much work on its main thread.
09-10 05:15:48.640: I/Choreographer(837): Skipped 34 frames!  The application may be doing too much work on its main thread.
09-10 05:15:50.350: I/Choreographer(837): Skipped 37 frames!  The application may be doing too much work on its main thread.
09-10 05:15:50.690: I/Choreographer(837): Skipped 32 frames!  The application may be doing too much work on its main thread.
09-10 05:15:51.150: I/Choreographer(837): Skipped 45 frames!  The application may be doing too much work on its main thread.
09-10 05:15:55.190: I/Choreographer(837): Skipped 31 frames!  The application may be doing too much work on its main thread.
09-10 05:15:56.040: I/Choreographer(837): Skipped 45 frames!  The application may be doing too much work on its main thread.
09-10 05:15:56.470: I/Choreographer(837): Skipped 30 frames!  The application may be doing too much work on its main thread.
09-10 05:15:58.470: I/Choreographer(837): Skipped 45 frames!  The application may be doing too much work on its main thread.
09-10 05:16:00.560: I/Choreographer(837): Skipped 52 frames!  The application may be doing too much work on its main thread.
09-10 05:16:00.710: I/Choreographer(837): Skipped 36 frames!  The application may be doing too much work on its main thread.
09-10 05:16:00.960: I/Choreographer(837): Skipped 36 frames!  The application may be doing too much work on its main thread.
09-10 05:16:01.290: I/Choreographer(837): Skipped 33 frames!  The application may be doing too much work on its main thread.
09-10 05:16:02.310: I/Choreographer(837): Skipped 43 frames!  The application may be doing too much work on its main thread.
09-10 05:16:02.730: D/dalvikvm(837): GC_FOR_ALLOC freed 227K, 8% free 3852K/4164K, paused 79ms, total 84ms
09-10 05:16:02.920: I/Choreographer(837): Skipped 111 frames!  The application may be doing too much work on its main thread.
09-10 05:16:03.030: W/ResourceType(837): No package identifier when getting value for resource number 0x00000000
09-10 05:16:03.040: D/AndroidRuntime(837): Shutting down VM
09-10 05:16:03.040: W/dalvikvm(837): threadid=1: thread exiting with uncaught exception (group=0xb3a16ba8)
09-10 05:16:03.070: E/AndroidRuntime(837): FATAL EXCEPTION: main
09-10 05:16:03.070: E/AndroidRuntime(837): Process: com.sj.jsondemo, PID: 837
09-10 05:16:03.070: E/AndroidRuntime(837): android.content.res.Resources$NotFoundException: Resource ID #0x0
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.content.res.Resources.getValue(Resources.java:1123)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.content.res.Resources.getDrawable(Resources.java:698)
09-10 05:16:03.070: E/AndroidRuntime(837):  at com.sj.jsondemo.ApplicationAdapter.getView(ApplicationAdapter.java:49)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.AbsListView.obtainView(AbsListView.java:2263)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.ListView.onMeasure(ListView.java:1175)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.View.measure(View.java:16497)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.View.measure(View.java:16497)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.View.measure(View.java:16497)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:16:03.070: E/AndroidRuntime(837):  at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.View.measure(View.java:16497)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-10 05:16:03.070: E/AndroidRuntime(837):  at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.View.measure(View.java:16497)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.Choreographer.doCallbacks(Choreographer.java:574)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.Choreographer.doFrame(Choreographer.java:544)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.os.Handler.handleCallback(Handler.java:733)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.os.Handler.dispatchMessage(Handler.java:95)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.os.Looper.loop(Looper.java:136)
09-10 05:16:03.070: E/AndroidRuntime(837):  at android.app.ActivityThread.main(ActivityThread.java:5017)
09-10 05:16:03.070: E/AndroidRuntime(837):  at java.lang.reflect.Method.invokeNative(Native Method)
09-10 05:16:03.070: E/AndroidRuntime(837):  at java.lang.reflect.Method.invoke(Method.java:515)
09-10 05:16:03.070: E/AndroidRuntime(837):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-10 05:16:03.070: E/AndroidRuntime(837):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-10 05:16:03.070: E/AndroidRuntime(837):  at dalvik.system.NativeStart.main(Native Method)
09-10 05:18:03.017: I/Process(837): Sending signal. PID: 837 SIG: 9
09-10 05:18:09.827: D/dalvikvm(1109): GC_FOR_ALLOC freed 47K, 5% free 2948K/3084K, paused 40ms, total 42ms
09-10 05:18:09.827: I/dalvikvm-heap(1109): Grow heap (frag case) to 3.565MB for 635812-byte allocation
09-10 05:18:09.887: D/dalvikvm(1109): GC_FOR_ALLOC freed 2K, 4% free 3566K/3708K, paused 54ms, total 54ms
09-10 05:18:10.417: I/Choreographer(1109): Skipped 53 frames!  The application may be doing too much work on its main thread.
09-10 05:18:10.437: D/gralloc_goldfish(1109): Emulator without GPU emulation detected.
09-10 05:18:10.627: I/Choreographer(1109): Skipped 42 frames!  The application may be doing too much work on its main thread.
09-10 05:18:11.317: I/Choreographer(1109): Skipped 74 frames!  The application may be doing too much work on its main thread.
09-10 05:18:12.397: I/Choreographer(1109): Skipped 40 frames!  The application may be doing too much work on its main thread.
09-10 05:18:13.217: I/Choreographer(1109): Skipped 38 frames!  The application may be doing too much work on its main thread.
09-10 05:18:13.577: I/Choreographer(1109): Skipped 34 frames!  The application may be doing too much work on its main thread.
09-10 05:18:14.157: I/Choreographer(1109): Skipped 39 frames!  The application may be doing too much work on its main thread.
09-10 05:18:17.097: D/dalvikvm(1109): GC_FOR_ALLOC freed 225K, 8% free 3855K/4164K, paused 33ms, total 37ms
09-10 05:18:17.187: I/Choreographer(1109): Skipped 66 frames!  The application may be doing too much work on its main thread.
09-10 05:18:17.307: W/ResourceType(1109): No package identifier when getting value for resource number 0x00000000
09-10 05:18:17.307: D/AndroidRuntime(1109): Shutting down VM
09-10 05:18:17.317: W/dalvikvm(1109): threadid=1: thread exiting with uncaught exception (group=0xb3a16ba8)
09-10 05:18:17.447: E/AndroidRuntime(1109): FATAL EXCEPTION: main
09-10 05:18:17.447: E/AndroidRuntime(1109): Process: com.sj.jsondemo, PID: 1109
09-10 05:18:17.447: E/AndroidRuntime(1109): android.content.res.Resources$NotFoundException: Resource ID #0x0
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.content.res.Resources.getValue(Resources.java:1123)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.content.res.Resources.getDrawable(Resources.java:698)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at com.sj.jsondemo.ApplicationAdapter.getView(ApplicationAdapter.java:49)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.AbsListView.obtainView(AbsListView.java:2263)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.ListView.onMeasure(ListView.java:1175)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16497)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16497)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16497)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16497)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.View.measure(View.java:16497)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.Choreographer.doCallbacks(Choreographer.java:574)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.Choreographer.doFrame(Choreographer.java:544)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.os.Handler.handleCallback(Handler.java:733)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.os.Handler.dispatchMessage(Handler.java:95)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.os.Looper.loop(Looper.java:136)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at android.app.ActivityThread.main(ActivityThread.java:5017)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at java.lang.reflect.Method.invokeNative(Native Method)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at java.lang.reflect.Method.invoke(Method.java:515)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-10 05:18:17.447: E/AndroidRuntime(1109):     at dalvik.system.NativeStart.main(Native Method)

and for the second attempt with new column:

09-10 05:25:34.410: D/dalvikvm(828): GC_FOR_ALLOC freed 47K, 5% free 2948K/3076K, paused 115ms, total 117ms
09-10 05:25:34.410: I/dalvikvm-heap(828): Grow heap (frag case) to 3.557MB for 635812-byte allocation
09-10 05:25:34.490: D/dalvikvm(828): GC_FOR_ALLOC freed 2K, 4% free 3566K/3700K, paused 70ms, total 71ms
09-10 05:25:35.040: I/Choreographer(828): Skipped 46 frames!  The application may be doing too much work on its main thread.
09-10 05:25:35.110: D/gralloc_goldfish(828): Emulator without GPU emulation detected.
09-10 05:25:35.280: I/Choreographer(828): Skipped 39 frames!  The application may be doing too much work on its main thread.
09-10 05:25:36.000: I/Choreographer(828): Skipped 155 frames!  The application may be doing too much work on its main thread.
09-10 05:25:38.910: I/Choreographer(828): Skipped 32 frames!  The application may be doing too much work on its main thread.
09-10 05:25:39.410: I/Choreographer(828): Skipped 30 frames!  The application may be doing too much work on its main thread.
09-10 05:25:42.960: I/Choreographer(828): Skipped 36 frames!  The application may be doing too much work on its main thread.
09-10 05:25:43.280: D/dalvikvm(828): GC_FOR_ALLOC freed 225K, 8% free 3855K/4156K, paused 70ms, total 73ms
09-10 05:25:43.540: I/Choreographer(828): Skipped 148 frames!  The application may be doing too much work on its main thread.
09-10 05:25:43.720: W/ResourceType(828): No package identifier when getting value for resource number 0x00000000
09-10 05:25:43.720: D/AndroidRuntime(828): Shutting down VM
09-10 05:25:43.720: W/dalvikvm(828): threadid=1: thread exiting with uncaught exception (group=0xb3affba8)
09-10 05:25:43.880: E/AndroidRuntime(828): FATAL EXCEPTION: main
09-10 05:25:43.880: E/AndroidRuntime(828): Process: com.sj.jsondemo, PID: 828
09-10 05:25:43.880: E/AndroidRuntime(828): android.content.res.Resources$NotFoundException: Resource ID #0x0
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.content.res.Resources.getValue(Resources.java:1123)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.content.res.Resources.getDrawable(Resources.java:698)
09-10 05:25:43.880: E/AndroidRuntime(828):  at com.sj.jsondemo.ApplicationAdapter.getView(ApplicationAdapter.java:49)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.AbsListView.obtainView(AbsListView.java:2263)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.ListView.measureHeightOfChildren(ListView.java:1263)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.ListView.onMeasure(ListView.java:1175)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.View.measure(View.java:16497)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.View.measure(View.java:16497)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.View.measure(View.java:16497)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:25:43.880: E/AndroidRuntime(828):  at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.View.measure(View.java:16497)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-10 05:25:43.880: E/AndroidRuntime(828):  at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.View.measure(View.java:16497)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.Choreographer.doCallbacks(Choreographer.java:574)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.Choreographer.doFrame(Choreographer.java:544)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.os.Handler.handleCallback(Handler.java:733)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.os.Handler.dispatchMessage(Handler.java:95)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.os.Looper.loop(Looper.java:136)
09-10 05:25:43.880: E/AndroidRuntime(828):  at android.app.ActivityThread.main(ActivityThread.java:5017)
09-10 05:25:43.880: E/AndroidRuntime(828):  at java.lang.reflect.Method.invokeNative(Native Method)
09-10 05:25:43.880: E/AndroidRuntime(828):  at java.lang.reflect.Method.invoke(Method.java:515)
09-10 05:25:43.880: E/AndroidRuntime(828):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-10 05:25:43.880: E/AndroidRuntime(828):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-10 05:25:43.880: E/AndroidRuntime(828):  at dalvik.system.NativeStart.main(Native Method)
Bulva
  • 1,208
  • 14
  • 28
  • The problem is not with the json. Is with some sort of drawable resource. What are you doing with setIcon(json.getString("icon"))? Also what code is on ApplicationAdapter.java:49? – Pedro Oliveira Sep 10 '14 at 09:31
  • There is this code: icon.setImageDrawable(res.getDrawable(res.getIdentifier(sIcon, null, null))); All code is on the web which I send above. I though it will be better and clearer than copy all code. – Bulva Sep 10 '14 at 09:37
  • What does the sIcon contain? Also try this code `icon.setImageDrawable(res.getDrawable(res.getIdentifier(sIcon, "drawable", this)));` – Pedro Oliveira Sep 10 '14 at 09:41
  • In sIcon is "com.sj.jsondemo:drawable/" + app.getIcon();. Here is block of if code which is there:if(icon != null) { Resources res = getContext().getResources(); String sIcon = "com.sj.jsondemo:drawable/" + app.getIcon(); icon.setImageDrawable(res.getDrawable(res.getIdentifier(sIcon, "drawable", this))); } When I try use your line it gives error The method get identifier(String, String, String) in the type of resources is not applicable for the arguments(St,St,apAdapter – Bulva Sep 10 '14 at 09:44
  • `if(icon != null) { Resources res = getContext().getResources(); icon.setImageDrawable(res.getDrawable(res.getIdentifier(app.getIcon(), "drawable", getContext().getPackageName()))); }` – Pedro Oliveira Sep 10 '14 at 09:46
  • It works the same like without my if statement. But with my if statement it doesn´t work. I want get some data from spinners in another activity so I first try it with variable which I made. So I want make the thing when in spinner will be rating 3 and I want populate listview only with data where rating equals 3. – Bulva Sep 10 '14 at 09:55
  • The problem is that the resource you are trying to use does not exist, therefore `Resources$NotFoundException`. Check if the app.getIcon() isn't returning empty or if you really have that icon on your drawable folder. – Pedro Oliveira Sep 10 '14 at 10:03
  • getIcon should works good and icons for app are in drawable. App works without my if statement in FetchDataTask.java – Bulva Sep 10 '14 at 10:10

0 Answers0