Issue with If-statement in getting data from MySQL - android

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)

Related

TextView cause an error on android emulator

I create TextView and set it to show value of some variable. The problem occur when I run android emulator, the application start normally, but when I click on the screen to let TextView show on screen, it's error.
This is LogCat of this application.
03-20 11:38:02.871: D/dalvikvm(3662): GC_FOR_ALLOC freed 86K, 5% free 3047K/3200K, paused 55ms, total 57ms
03-20 11:38:02.901: I/dalvikvm-heap(3662): Grow heap (frag case) to 4.930MB for 1987216-byte allocation
03-20 11:38:02.951: D/dalvikvm(3662): GC_FOR_ALLOC freed 2K, 4% free 4985K/5144K, paused 42ms, total 42ms
03-20 11:38:03.981: I/Choreographer(3662): Skipped 30 frames! The application may be doing too much work on its main thread.
03-20 11:38:04.031: D/gralloc_goldfish(3662): Emulator without GPU emulation detected.
03-20 11:38:16.111: I/Choreographer(3662): Skipped 345 frames! The application may be doing too much work on its main thread.
03-20 11:38:22.541: W/ResourceType(3662): No package identifier when getting value for resource number 0x00000001
03-20 11:38:22.551: D/AndroidRuntime(3662): Shutting down VM
03-20 11:38:22.551: W/dalvikvm(3662): threadid=1: thread exiting with uncaught exception (group=0xb1af5ba8)
03-20 11:38:22.601: E/AndroidRuntime(3662): FATAL EXCEPTION: main
03-20 11:38:22.601: E/AndroidRuntime(3662): Process: com.example.yyy, PID: 3662
03-20 11:38:22.601: E/AndroidRuntime(3662): android.content.res.Resources$NotFoundException: String resource ID #0x1
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.content.res.Resources.getText(Resources.java:244)
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.widget.TextView.setText(TextView.java:3888)
03-20 11:38:22.601: E/AndroidRuntime(3662): at com.example.yyy.Find2Activity.onClick(Find2Activity.java:167)
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.view.View.performClick(View.java:4438)
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.view.View$PerformClick.run(View.java:18422)
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.os.Handler.handleCallback(Handler.java:733)
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.os.Handler.dispatchMessage(Handler.java:95)
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.os.Looper.loop(Looper.java:136)
03-20 11:38:22.601: E/AndroidRuntime(3662): at android.app.ActivityThread.main(ActivityThread.java:5017)
03-20 11:38:22.601: E/AndroidRuntime(3662): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 11:38:22.601: E/AndroidRuntime(3662): at java.lang.reflect.Method.invoke(Method.java:515)
03-20 11:38:22.601: E/AndroidRuntime(3662): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-20 11:38:22.601: E/AndroidRuntime(3662): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-20 11:38:22.601: E/AndroidRuntime(3662): at dalvik.system.NativeStart.main(Native Method)
03-20 11:38:27.071: I/Process(3662): Sending signal. PID: 3662 SIG: 9
android.content.res.Resources$NotFoundException: String resource ID #0x1
The stacktrace is telling you that you are calling yourTextView.setText(1);, with 1
as int value. Change it to yourTextView.setText(""+1); to convert that value to String.
If you pass a int to setText android will try to look up for a String with id the int you provided

Calling autoFocus() from parent Activity returns NPE

I have instantiated a fragment type that extends CameraFragment (and implements TabListener), and I am trying to call the autoFocus() from the the parent Activity. Calling autoFocus() from the fragment that extends CameraFragment works fine, but calling it from the parent Activity results in an NPE. I am listening for a onKeyDown() event in the main Activity, which works as expected as per the logcat. Here is my NPE trace:
09-10 10:00:16.410: D/app(5283): onKeyDown: 80
09-10 10:00:16.415: D/AndroidRuntime(5283): Shutting down VM
09-10 10:00:16.415: W/dalvikvm(5283): threadid=1: thread exiting with uncaught exception (group=0x40f7b2a0)
09-10 10:00:16.425: E/AndroidRuntime(5283): FATAL EXCEPTION: main
09-10 10:00:16.425: E/AndroidRuntime(5283): java.lang.NullPointerException
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.commonsware.cwac.camera.CameraFragment.autoFocus(CameraFragment.java:96)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.me.app.appCameraFragment.callAutoFocus(cameraFragment.java:232)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.me.app.MainTabActivity.onKeyDown(MainTabActivity.java:264)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.KeyEvent.dispatch(KeyEvent.java:2705)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.app.Activity.dispatchKeyEvent(Activity.java:2423)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2019)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3851)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3799)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2934)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.os.Looper.loop(Looper.java:137)
09-10 10:00:16.425: E/AndroidRuntime(5283): at android.app.ActivityThread.main(ActivityThread.java:4921)
09-10 10:00:16.425: E/AndroidRuntime(5283): at java.lang.reflect.Method.invokeNative(Native Method)
09-10 10:00:16.425: E/AndroidRuntime(5283): at java.lang.reflect.Method.invoke(Method.java:511)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036)
09-10 10:00:16.425: E/AndroidRuntime(5283): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
09-10 10:00:16.425: E/AndroidRuntime(5283): at dalvik.system.NativeStart.main(Native Method)
I'm not sure what version of the code you are working on, but line 96 is a closing brace in the current CameraFragment.
The only way autoFocus() can crash with a NullPointerException is if cameraView is null, and the only way cameraView should be null is if onCreateView() has not yet been called. You need the fragment to be visible and fully created before you request auto-focus.

App runs fine on phones, crashes on tablets

My app runs fine on phone crashes on start up on tablets. It runs fine on my phone running 2.3.7 and my sister's phone running 4.0.3. But it crashes on my 10.1" tablet running 4.0.4. I tried it on a Nexus 7 AVD running 4.2 and it crashes there too.
This is the Log
12-26 23:11:55.350: E/Trace(845): error opening trace file: No such file or directory (2)
12-26 23:11:55.350: W/Trace(845): Unexpected value from nativeGetEnabledTags: 0
12-26 23:11:55.350: W/Trace(845): Unexpected value from nativeGetEnabledTags: 0
12-26 23:11:55.350: W/Trace(845): Unexpected value from nativeGetEnabledTags: 0
12-26 23:11:55.560: W/Trace(845): Unexpected value from nativeGetEnabledTags: 0
12-26 23:11:55.560: W/Trace(845): Unexpected value from nativeGetEnabledTags: 0
12-26 23:11:56.741: D/dalvikvm(845): GC_CONCURRENT freed 217K, 12% free 2635K/2984K, paused 70ms+14ms, total 139ms
12-26 23:11:56.751: D/dalvikvm(845): WAIT_FOR_CONCURRENT_GC blocked 4ms
12-26 23:11:56.813: D/dalvikvm(845): GC_FOR_ALLOC freed 68K, 14% free 2666K/3084K, paused 52ms, total 53ms
12-26 23:11:56.821: I/dalvikvm-heap(845): Grow heap (frag case) to 3.333MB for 635812-byte allocation
12-26 23:11:56.881: D/dalvikvm(845): GC_FOR_ALLOC freed <1K, 12% free 3286K/3708K, paused 57ms, total 57ms
12-26 23:11:56.931: D/dalvikvm(845): GC_CONCURRENT freed <1K, 12% free 3287K/3708K, paused 9ms+3ms, total 52ms
12-26 23:11:56.931: D/dalvikvm(845): WAIT_FOR_CONCURRENT_GC blocked 12ms
12-26 23:11:56.931: I/dalvikvm-heap(845): Grow heap (frag case) to 3.811MB for 500416-byte allocation
12-26 23:11:57.011: D/dalvikvm(845): GC_FOR_ALLOC freed <1K, 11% free 3775K/4200K, paused 49ms, total 49ms
12-26 23:11:57.223: D/AndroidRuntime(845): Shutting down VM
12-26 23:11:57.223: W/dalvikvm(845): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
12-26 23:11:57.231: E/AndroidRuntime(845): FATAL EXCEPTION: main
12-26 23:11:57.231: E/AndroidRuntime(845): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.brandsonicinc.brandsonic.web.mobile/com.brandsonicinc.brandsonic.web.mobile.MainActivity}: java.lang.NullPointerException
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.os.Looper.loop(Looper.java:137)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-26 23:11:57.231: E/AndroidRuntime(845): at java.lang.reflect.Method.invokeNative(Native Method)
12-26 23:11:57.231: E/AndroidRuntime(845): at java.lang.reflect.Method.invoke(Method.java:511)
12-26 23:11:57.231: E/AndroidRuntime(845): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-26 23:11:57.231: E/AndroidRuntime(845): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-26 23:11:57.231: E/AndroidRuntime(845): at dalvik.system.NativeStart.main(Native Method)
12-26 23:11:57.231: E/AndroidRuntime(845): Caused by: java.lang.NullPointerException
12-26 23:11:57.231: E/AndroidRuntime(845): at com.brandsonicinc.brandsonic.web.mobile.MainActivity.onCreate(MainActivity.java:84)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.Activity.performCreate(Activity.java:5104)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-26 23:11:57.231: E/AndroidRuntime(845): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-26 23:11:57.231: E/AndroidRuntime(845): ... 11 more
12-26 23:12:02.487: W/chromium(845): external/chromium/net/disk_cache/backend_impl.cc:1835: [1226/231202:WARNING:backend_impl.cc(1835)] Destroying invalid entry.
12-26 23:12:02.500: E/chromium(845): external/chromium/net/disk_cache/backend_impl.cc:1107: [1226/231202:ERROR:backend_impl.cc(1107)] Critical error found -8
12-26 23:12:02.820: W/chromium(845): external/chromium/net/disk_cache/storage_block-inl.h:119: [1226/231202:WARNING:storage_block-inl.h(119)] Failed data load.
12-26 23:12:02.820: W/chromium(845): external/chromium/net/disk_cache/storage_block-inl.h:119: [1226/231202:WARNING:storage_block-inl.h(119)] Failed data load.
12-26 23:12:02.840: W/chromium(845): external/chromium/net/disk_cache/storage_block-inl.h:119: [1226/231202:WARNING:storage_block-inl.h(119)] Failed data load.
12-26 23:12:02.881: W/chromium(845): external/chromium/net/disk_cache/storage_block-inl.h:119: [1226/231202:WARNING:storage_block-inl.h(119)] Failed data load.
12-26 23:12:02.966: E/chromium(845): external/chromium/net/disk_cache/entry_impl.cc:904: [1226/231202:ERROR:entry_impl.cc(904)] Failed to save user data
12-26 23:12:02.971: E/chromium(845): external/chromium/net/disk_cache/entry_impl.cc:904: [1226/231202:ERROR:entry_impl.cc(904)] Failed to save user data
12-26 23:12:04.361: I/Process(845): Sending signal. PID: 845 SIG: 9
Please help this is very frustrating. It used to run fine on tablets. Could it have something to do with the layouts?
try to put all your xml files in layout folder and no need to remove it from other if it already there.
If xml files are in folders like layout-sw600dp then the device will fail to load the specified xml file if screen width is less than 600dp. this is just example in your case it may be different
I have read your log, there is a bug on finding directory, have you use some directory method, to retrieve file from a particular location, tablet have internal storage instead of sd card might be problem in that.
But I can better understand if you post the code.

NullPointerexception in itemizedOverlay [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
in android application I am using the Google API for maps. I got the following exception. I want to know what exactly this exception means ?
10-19 23:45:06.619: E/AndroidRuntime(837): FATAL EXCEPTION: main
10-19 23:45:06.619: E/AndroidRuntime(837): java.lang.NullPointerException
10-19 23:45:06.619: E/AndroidRuntime(837): at com.google.android.maps.ItemizedOverlay.getItemsAtLocation(ItemizedOverlay.java:617)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.google.android.maps.ItemizedOverlay.getItemAtLocation(ItemizedOverlay.java:586)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.google.android.maps.ItemizedOverlay.handleMotionEvent(ItemizedOverlay.java:498)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.google.android.maps.ItemizedOverlay.onTouchEvent(ItemizedOverlay.java:572)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.google.android.maps.OverlayBundle.onTouchEvent(OverlayBundle.java:63)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.google.android.maps.MapView.onTouchEvent(MapView.java:679)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.View.dispatchTouchEvent(View.java:3885)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.os.Handler.dispatchMessage(Handler.java:99)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.os.Looper.loop(Looper.java:130)
10-19 23:45:06.619: E/AndroidRuntime(837): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-19 23:45:06.619: E/AndroidRuntime(837): at java.lang.reflect.Method.invokeNative(Native Method)
10-19 23:45:06.619: E/AndroidRuntime(837): at java.lang.reflect.Method.invoke(Method.java:507)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-19 23:45:06.619: E/AndroidRuntime(837): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-19 23:45:06.619: E/AndroidRuntime(837): at dalvik.system.NativeStart.main(Native Method)
The sound like you forgot to add populate() in the constructor.
It should be like:
LocationItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
this.context = context;
populate(); // Add this
}
.....
Its happens on moving map

bitmap size exceeds VM budget...how to solve this error?

I have gone through so many posts related to this error but not getting proper solution for my problem.
there are three activities in my projec..in each acivity there are 4 animations for which i am using sequences. on onclick to change my activity i am getting vm budget out of memory error.
How to clear memory of an acivity while we are going to other activity? so that memory could be used for next activity..
thanks in advance for help...
Error occuring is as below....
09-10 10:35:12.046: ERROR/AndroidRuntime(472): FATAL EXCEPTION: main
09-10 10:35:12.046: ERROR/AndroidRuntime(472): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.Bitmap.nativeCreate(Native Method)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.content.res.Resources.loadDrawable(Resources.java:1709)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.content.res.Resources.getDrawable(Resources.java:581)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:265)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:788)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:729)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.content.res.Resources.loadDrawable(Resources.java:1694)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.content.res.Resources.getDrawable(Resources.java:581)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.view.View.setBackgroundResource(View.java:7393)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at com.bokstverna.InnerActivityR.onCreate(InnerActivityR.java:87)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.os.Looper.loop(Looper.java:123)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at java.lang.reflect.Method.invokeNative(Native Method)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at java.lang.reflect.Method.invoke(Method.java:521)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-10 10:35:12.046: ERROR/AndroidRuntime(472): at dalvik.system.NativeStart.main(Native Method)
U have to scale ur bitmap like below,
img.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 200,200, true));
then its size will not exceed.It will fix to a particular size.

Categories

Resources