I need to do an HTTP post of information including String byte representations of multiple files in a single HTTP Post. I'm getting quite a lot of byte allocation errors and was wondering if there was a better way of storing this information for later post to server?
I've basically taken quite a few picture files, and I'm packaging them up into a single HTTP Post string of the format:
name="string byte representation of picture file"×tamp="time"&gps="latitude""longitude",etc.
Logcat:
03-09 22:26:41.329: E/dalvikvm-heap(8716): Out of memory on a 5932438-byte allocation.
03-09 22:26:41.329: I/dalvikvm(8716): "main" prio=5 tid=1 RUNNABLE
03-09 22:26:41.329: I/dalvikvm(8716): | group="main" sCount=0 dsCount=0 s=N obj=0x40020ba0 self=0xddd0
03-09 22:26:41.329: I/dalvikvm(8716): | sysTid=8716 nice=0 sched=0/0 cgrp=unknown handle=-1345025972
03-09 22:26:41.329: I/dalvikvm(8716): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~97)
03-09 22:26:41.329: I/dalvikvm(8716): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:157)
03-09 22:26:41.329: I/dalvikvm(8716): at java.lang.StringBuilder.append(StringBuilder.java:217)
03-09 22:26:41.329: I/dalvikvm(8716): at mfc.generalguixapi8.SaveData2.saveData(SaveData2.java:169)
03-09 22:26:41.329: I/dalvikvm(8716): at mfc.generalguixapi8.SaveData2.onCreate(SaveData2.java:34)
03-09 22:26:41.329: I/dalvikvm(8716): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-09 22:26:41.329: I/dalvikvm(8716): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-09 22:26:41.329: I/dalvikvm(8716): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-09 22:26:41.329: I/dalvikvm(8716): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-09 22:26:41.329: I/dalvikvm(8716): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-09 22:26:41.329: I/dalvikvm(8716): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 22:26:41.329: I/dalvikvm(8716): at android.os.Looper.loop(Looper.java:123)
03-09 22:26:41.329: I/dalvikvm(8716): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-09 22:26:41.339: I/dalvikvm(8716): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 22:26:41.339: I/dalvikvm(8716): at java.lang.reflect.Method.invoke(Method.java:521)
03-09 22:26:41.339: I/dalvikvm(8716): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-09 22:26:41.339: I/dalvikvm(8716): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-09 22:26:41.339: I/dalvikvm(8716): at dalvik.system.NativeStart.main(Native Method)
03-09 22:26:41.339: W/dalvikvm(8716): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
03-09 22:26:41.339: E/AndroidRuntime(8716): FATAL EXCEPTION: main
03-09 22:26:41.339: E/AndroidRuntime(8716): java.lang.OutOfMemoryError
03-09 22:26:41.339: E/AndroidRuntime(8716): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:97)
03-09 22:26:41.339: E/AndroidRuntime(8716): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:157)
03-09 22:26:41.339: E/AndroidRuntime(8716): at java.lang.StringBuilder.append(StringBuilder.java:217)
03-09 22:26:41.339: E/AndroidRuntime(8716): at mfc.generalguixapi8.SaveData2.saveData(SaveData2.java:169)
03-09 22:26:41.339: E/AndroidRuntime(8716): at mfc.generalguixapi8.SaveData2.onCreate(SaveData2.java:34)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.os.Looper.loop(Looper.java:123)
03-09 22:26:41.339: E/AndroidRuntime(8716): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-09 22:26:41.339: E/AndroidRuntime(8716): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 22:26:41.339: E/AndroidRuntime(8716): at java.lang.reflect.Method.invoke(Method.java:521)
03-09 22:26:41.339: E/AndroidRuntime(8716): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-09 22:26:41.339: E/AndroidRuntime(8716): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-09 22:26:41.339: E/AndroidRuntime(8716): at dalvik.system.NativeStart.main(Native Method)
The problem can be solved using Sending file > 1MB using HTTP POST
I was getting an OutofMemory issue in the above link, and solved it by saving the data to a FileOutputStream and sending the information to the server in chunks.
Related
Here is a link to a question i posted before with my code:
https://stackoverflow.com/questions/22277864/grid-view-open-one-layout-form-another-causes-the-prograam-to-crash
The error happens right as I click on the button2 'Ornaments' on the main form .
Log Cat:
03-09 10:08:20.308: E/Trace(640): error opening trace file: No such file or directory (2)
03-09 10:08:21.158: D/libEGL(640): loaded /system/lib/egl/libEGL_emulation.so
03-09 10:08:21.158: D/(640): HostConnection::get() New Host Connection established 0x2a072918, tid 640
03-09 10:08:21.218: D/libEGL(640): loaded /system/lib/egl/libGLESv1_CM_emulation.so
03-09 10:08:21.229: D/libEGL(640): loaded /system/lib/egl/libGLESv2_emulation.so
03-09 10:08:21.338: W/EGL_emulation(640): eglSurfaceAttrib not implemented
03-09 10:08:21.378: D/OpenGLRenderer(640): Enabling debug mode 0
03-09 10:08:26.648: D/dalvikvm(640): GC_FOR_ALLOC freed 125K, 3% free 8250K/8455K, paused 118ms, total 130ms
03-09 10:08:26.648: I/dalvikvm-heap(640): Forcing collection of SoftReferences for 31961104-byte allocation
03-09 10:08:26.838: D/dalvikvm(640): GC_BEFORE_OOM freed 13K, 3% free 8236K/8455K, paused 184ms, total 185ms
03-09 10:08:26.838: E/dalvikvm-heap(640): Out of memory on a 31961104-byte allocation.
03-09 10:08:26.838: I/dalvikvm(640): "main" prio=5 tid=1 RUNNABLE
03-09 10:08:26.848: I/dalvikvm(640): | group="main" sCount=0 dsCount=0 obj=0x40a14568 self=0x2a00b9e0
03-09 10:08:26.848: I/dalvikvm(640): | sysTid=640 nice=0 sched=0/0 cgrp=apps handle=1073870640
03-09 10:08:26.848: I/dalvikvm(640): | schedstat=( 1310216641 1726854966 299 ) utm=92 stm=39 core=0
03-09 10:08:26.858: I/dalvikvm(640): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
03-09 10:08:26.858: I/dalvikvm(640): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
03-09 10:08:26.858: I/dalvikvm(640): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
03-09 10:08:26.873: I/dalvikvm(640): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
03-09 10:08:26.878: I/dalvikvm(640): at android.content.res.Resources.loadDrawable(Resources.java:1930)
03-09 10:08:26.878: I/dalvikvm(640): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
03-09 10:08:26.878: I/dalvikvm(640): at android.widget.ImageView.<init>(ImageView.java:120)
03-09 10:08:26.878: I/dalvikvm(640): at android.widget.ImageView.<init>(ImageView.java:110)
03-09 10:08:26.878: I/dalvikvm(640): at java.lang.reflect.Constructor.constructNative(Native Method)
03-09 10:08:26.878: I/dalvikvm(640): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-09 10:08:26.878: I/dalvikvm(640): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-09 10:08:26.888: I/dalvikvm(640): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-09 10:08:26.888: I/dalvikvm(640): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
03-09 10:08:26.888: I/dalvikvm(640): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
03-09 10:08:26.888: I/dalvikvm(640): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-09 10:08:26.888: I/dalvikvm(640): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-09 10:08:26.888: I/dalvikvm(640): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-09 10:08:26.898: I/dalvikvm(640): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-09 10:08:26.898: I/dalvikvm(640): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
03-09 10:08:26.898: I/dalvikvm(640): at android.app.Activity.setContentView(Activity.java:1867)
03-09 10:08:26.898: I/dalvikvm(640): at edu.ajh161.designs.Ornaments.onCreate(Ornaments.java:13)
03-09 10:08:26.898: I/dalvikvm(640): at android.app.Activity.performCreate(Activity.java:5008)
03-09 10:08:26.910: I/dalvikvm(640): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-09 10:08:26.910: I/dalvikvm(640): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
03-09 10:08:26.910: I/dalvikvm(640): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
03-09 10:08:26.910: I/dalvikvm(640): at android.app.ActivityThread.access$600(ActivityThread.java:130)
03-09 10:08:26.910: I/dalvikvm(640): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
03-09 10:08:26.910: I/dalvikvm(640): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 10:08:26.910: I/dalvikvm(640): at android.os.Looper.loop(Looper.java:137)
03-09 10:08:26.918: I/dalvikvm(640): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-09 10:08:26.918: I/dalvikvm(640): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 10:08:26.918: I/dalvikvm(640): at java.lang.reflect.Method.invoke(Method.java:511)
03-09 10:08:26.918: I/dalvikvm(640): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-09 10:08:26.918: I/dalvikvm(640): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-09 10:08:26.918: I/dalvikvm(640): at dalvik.system.NativeStart.main(Native Method)
03-09 10:08:26.928: D/skia(640): --- decoder->decode returned false
03-09 10:08:26.948: D/AndroidRuntime(640): Shutting down VM
03-09 10:08:26.958: W/dalvikvm(640): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
03-09 10:08:27.138: E/AndroidRuntime(640): FATAL EXCEPTION: main
03-09 10:08:27.138: E/AndroidRuntime(640): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.ajh161.designs/edu.ajh161.designs.Ornaments}: android.view.InflateException: Binary XML file line #34: Error inflating class <unknown>
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.ActivityThread.access$600(ActivityThread.java:130)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.os.Looper.loop(Looper.java:137)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.ActivityThread.main(ActivityThread.java:4745)
03-09 10:08:27.138: E/AndroidRuntime(640): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 10:08:27.138: E/AndroidRuntime(640): at java.lang.reflect.Method.invoke(Method.java:511)
03-09 10:08:27.138: E/AndroidRuntime(640): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
03-09 10:08:27.138: E/AndroidRuntime(640): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-09 10:08:27.138: E/AndroidRuntime(640): at dalvik.system.NativeStart.main(Native Method)
03-09 10:08:27.138: E/AndroidRuntime(640): Caused by: android.view.InflateException: Binary XML file line #34: Error inflating class <unknown>
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-09 10:08:27.138: E/AndroidRuntime(640): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-09 10:08:27.138: E/AndroidRuntime(640): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.Activity.setContentView(Activity.java:1867)
03-09 10:08:27.138: E/AndroidRuntime(640): at edu.ajh161.designs.Ornaments.onCreate(Ornaments.java:13)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.Activity.performCreate(Activity.java:5008)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
03-09 10:08:27.138: E/AndroidRuntime(640): ... 11 more
03-09 10:08:27.138: E/AndroidRuntime(640): Caused by: java.lang.reflect.InvocationTargetException
03-09 10:08:27.138: E/AndroidRuntime(640): at java.lang.reflect.Constructor.constructNative(Native Method)
03-09 10:08:27.138: E/AndroidRuntime(640): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-09 10:08:27.138: E/AndroidRuntime(640): ... 24 more
03-09 10:08:27.138: E/AndroidRuntime(640): Caused by: java.lang.OutOfMemoryError
03-09 10:08:27.138: E/AndroidRuntime(640): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.content.res.Resources.loadDrawable(Resources.java:1930)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.widget.ImageView.<init>(ImageView.java:120)
03-09 10:08:27.138: E/AndroidRuntime(640): at android.widget.ImageView.<init>(ImageView.java:110)
03-09 10:08:27.138: E/AndroidRuntime(640): ... 27 more
03-09 10:08:31.238: I/Process(640): Sending signal. PID: 640 SIG: 9
Here, you are getting 3 Exceptions:
android.view.InflateException
java.lang.reflect.InvocationTargetException
java.lang.OutOfMemoryError
The problem starts to occurring from OutOfMemoryError Exception. The drawable, you are trying to set in the ImageView with the id imageview2, may be too large. So, when system trying to process that drawable it exceeds memory limit...then OutOfMemoryError Exception occurring.
Since, due to the OutOfMemoryError, system can't set that drawable to tha ImageView then its throwing other Exceptions as InvocationTargetException and InflateException.
Now, try to reduce the drawable's size...may be your problem will be solved.
I am trying to access the Wifi and switch it ON and OFF.
here the logcat :
03-09 20:30:45.601: I/Process(28690): Sending signal. PID: 28690 SIG: 9
03-09 20:30:45.932: D/AbsListView(28891): Get MotionRecognitionManager
03-09 20:30:45.982: D/AbsListView(28891): unregisterIRListener() is called
03-09 20:30:46.002: D/libEGL(28891): loaded /vendor/lib/egl/libEGL_adreno.so
03-09 20:30:46.002: D/libEGL(28891): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
03-09 20:30:46.012: D/libEGL(28891): loaded /vendor/lib/egl/libGLESv2_adreno.so
03-09 20:30:46.012: I/Adreno-EGL(28891): <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build: (CL4169980)
03-09 20:30:46.012: I/Adreno-EGL(28891): OpenGL ES Shader Compiler Version: 17.01.10.SPL
03-09 20:30:46.012: I/Adreno-EGL(28891): Build Date: 09/26/13 Thu
03-09 20:30:46.012: I/Adreno-EGL(28891): Local Branch:
03-09 20:30:46.012: I/Adreno-EGL(28891): Remote Branch:
03-09 20:30:46.012: I/Adreno-EGL(28891): Local Patches:
03-09 20:30:46.012: I/Adreno-EGL(28891): Reconstruct Branch:
03-09 20:30:46.052: D/OpenGLRenderer(28891): Enabling debug mode 0
03-09 20:30:46.052: D/AbsListView(28891): unregisterIRListener() is called
03-09 20:30:46.122: D/AbsListView(28891): unregisterIRListener() is called
03-09 20:30:46.142: D/AbsListView(28891): unregisterIRListener() is called
03-09 20:30:48.724: E/InputEventReceiver(28891): Exception dispatching input event.
03-09 20:30:48.724: D/AndroidRuntime(28891): Shutting down VM
03-09 20:30:48.724: W/dalvikvm(28891): threadid=1: thread exiting with uncaught exception (group=0x41d34898)
03-09 20:30:48.764: E/AndroidRuntime(28891): FATAL EXCEPTION: main
03-09 20:30:48.764: E/AndroidRuntime(28891): java.lang.NullPointerException
03-09 20:30:48.764: E/AndroidRuntime(28891): at com.AliTooq.locationtasklauncer.ActionManager.wifiOff(ActionManager.java:158)
03-09 20:30:48.764: E/AndroidRuntime(28891): at com.AliTooq.locationtasklauncer.ActionManager.activate(ActionManager.java:43)
03-09 20:30:48.764: E/AndroidRuntime(28891): at com.AliTooq.locationtasklauncer.Profile.activate(Profile.java:126)
03-09 20:30:48.764: E/AndroidRuntime(28891): at com.AliTooq.locationtasklauncer.ProfileFragment$1.onItemClick(ProfileFragment.java:39)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.widget.AdapterView.performItemClick(AdapterView.java:301)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.widget.AbsListView.performItemClick(AbsListView.java:1507)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3336)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.widget.AbsListView.onTouchEvent(AbsListView.java:4632)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.View.dispatchTouchEvent(View.java:7817)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2435)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2159)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2441)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2174)
03-09 20:30:48.764: E/AndroidRuntime(28891): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2326)
03-09 20:30:48.764: E/AndroidRuntime(28891): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1612)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.app.Activity.dispatchTouchEvent(Activity.java:2494)
03-09 20:30:48.764: E/AndroidRuntime(28891): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2274)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.View.dispatchPointerEvent(View.java:8025)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4659)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4547)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4148)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4198)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4167)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4252)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4175)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4309)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4148)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4198)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4167)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4175)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4148)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6293)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6231)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6202)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6373)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:188)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:177)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6346)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6392)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
03-09 20:30:48.764: E/AndroidRuntime(28891): at android.view.Choreogra
03-09 20:30:50.576: I/Process(28891): 9Sending signal. PID: 28891 SIG: 9
the Method that turn wifi off is :
public void wifiOff()
{
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.setWifiEnabled(false);}
I don't know what is the cause of the problem. I have changed the class to active and it still get the same error.
Also I am sure about my permissions in Mainfest file.
You probably forgot to add the permissions. Not sure if all of them are needed, but first two for sure.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
I have a problem when I run my app and select an item from my spinner instead of opening a new class like it is supposed to the app crashes, I was wondering if anyone could help me with why this is happening. I am not sure what part of the code to include, so I will include the Logcat and if you request any code I will edit this post.
Thanks.
Logcat:
03-09 15:36:53.814: E/AndroidRuntime(13429): FATAL EXCEPTION: main
03-09 15:36:53.814: E/AndroidRuntime(13429): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.famouspeople/com.example.famouspeople.SeanConnery}: java.lang.NullPointerException
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.os.Looper.loop(Looper.java:137)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-09 15:36:53.814: E/AndroidRuntime(13429): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 15:36:53.814: E/AndroidRuntime(13429): at java.lang.reflect.Method.invoke(Method.java:511)
03-09 15:36:53.814: E/AndroidRuntime(13429): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-09 15:36:53.814: E/AndroidRuntime(13429): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-09 15:36:53.814: E/AndroidRuntime(13429): at dalvik.system.NativeStart.main(Native Method)
03-09 15:36:53.814: E/AndroidRuntime(13429): Caused by: java.lang.NullPointerException
03-09 15:36:53.814: E/AndroidRuntime(13429): at com.example.famouspeople.SeanConnery.initialize(SeanConnery.java:44)
03-09 15:36:53.814: E/AndroidRuntime(13429): at com.example.famouspeople.SeanConnery.onCreate(SeanConnery.java:28)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.Activity.performCreate(Activity.java:5206)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-09 15:36:53.814: E/AndroidRuntime(13429): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-09 15:36:53.814: E/AndroidRuntime(13429): ... 11 more
Normally when app crashes with the click on spinner, the problem lies with the adapter you are using to populate the spinner, check carefully the length of apapter you defined. Follow this code
int num = SpinnerData.length;
SpinnerData = new String[num];
Log.d("ArrayAdapter",""+ SpinnerData.length);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(CurrentActivity.this, android.R.layout.simple_list_item_1, SpinnerData);
//spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(spinnerArrayAdapter);
check carefully length ..I hope this help
Trying to develop hello world, but getting force close error on emulator. thanks in advance
07-25 12:04:12.308: D/AndroidRuntime(277): Shutting down VM
07-25 12:04:12.308: W/dalvikvm(277): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-25 12:04:12.368: E/AndroidRuntime(277): FATAL EXCEPTION: main
07-25 12:04:12.368: E/AndroidRuntime(277): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.exampe.helloww/com.exampe.helloww.HelloActivity}: java.lang.ClassNotFoundException: com.exampe.helloww.HelloActivity in loader dalvik.system.PathClassLoader[/data/app/com.exampe.helloww-2.apk]
07-25 12:04:12.368: E/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:99)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-25 12:04:12.368: E/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
07-25 12:04:12.368: E/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
07-25 12:04:12.368: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-25 12:04:12.368: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-25 12:04:12.368: E/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)
07-25 12:04:12.368: E/AndroidRuntime(277): Caused by: java.lang.ClassNotFoundException: com.exampe.helloww.HelloActivity in loader dalvik.system.PathClassLoader[/data/app/com.exampe.helloww-2.apk]
07-25 12:04:12.368: E/AndroidRuntime(277): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-25 12:04:12.368: E/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-25 12:04:12.368: E/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-25 12:04:12.368: E/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
07-25 12:04:12.368: E/AndroidRuntime(277): ... 11 more
07-25 12:04:17.158: I/Process(277): Sending signal. PID: 277 SIG: 9
the ClassNotFoundException is usually caused when you try to run your app on lower sdk version than the target sdk
Add your HelloActivity in Manifest file.Due to this your Activity is not found and you are getting ClassNotFoundException as
E/AndroidRuntime(277): Caused by: java.lang.ClassNotFoundException: com.exampe.helloww.HelloActivity
While binding the MediaPlaybackService in android 4.0.3 throws an exception as follows :
03-09 09:51:08.399: ERROR/AndroidRuntime(664): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sudarmuthu.android.adjustvolume/com.sudarmuthu.android.adjustvolume.AdjustVolume}: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.android.music/.MediaPlaybackService }
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.os.Looper.loop(Looper.java:137)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at java.lang.reflect.Method.invoke(Method.java:511)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at dalvik.system.NativeStart.main(Native Method)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.android.music/.MediaPlaybackService }
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.ContextImpl.bindService(ContextImpl.java:1135)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.content.ContextWrapper.bindService(ContextWrapper.java:370)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at com.sudarmuthu.android.adjustvolume.AdjustVolume.onStart(AdjustVolume.java:153)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.Activity.performStart(Activity.java:4475)
03-09 09:51:08.399: ERROR/AndroidRuntime(664): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1929)
This application is smoothly running in android 2.1 versions.
Any Help!!
Please refer this link http://groups.google.com/group/android-developers/browse_thread/thread/a03ea845989a49ba , I think this will help you...