Android - why is GC suddenly removing my object? - android

When I'm creating object to write to output stream (size is lower than 150KB) it probably gets instantly destroyed, because of:
System.out.println("Sending object..");
Packet p = new Packet(mJpegData); // here exists
System.out.println(p); // reference exists
oos.writeObject(p); // null exception error
full error:
04-26 21:37:01.414: W/System.err(12888): java.lang.NullPointerException
04-26 21:37:01.414: W/System.err(12888): at pl.aadamczyk.webcamera.Preview$PreCallback.onPreviewFrame(Preview.java:148)
04-26 21:37:01.417: W/System.err(12888): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:583)
04-26 21:37:01.417: W/System.err(12888): at android.os.Handler.dispatchMessage(Handler.java:99)
04-26 21:37:01.417: W/System.err(12888): at android.os.Looper.loop(Looper.java:130)
04-26 21:37:01.417: W/System.err(12888): at android.app.ActivityThread.main(ActivityThread.java:3687)
04-26 21:37:01.417: W/System.err(12888): at java.lang.reflect.Method.invokeNative(Native Method)
04-26 21:37:01.417: W/System.err(12888): at java.lang.reflect.Method.invoke(Method.java:507)
04-26 21:37:01.417: W/System.err(12888): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
04-26 21:37:01.417: W/System.err(12888): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
04-26 21:37:01.417: W/System.err(12888): at dalvik.system.NativeStart.main(Native Method)
04-26 21:37:01.472: D/dalvikvm(12888): GC_FOR_MALLOC freed 1152K, 57% free 2820K/6535K, external 1596K/2108K, paused 17ms
04-26 21:37:01.472: I/System.out(12888): My Object has been GC'd. Packet#4063d908
04-26 21:37:01.523: D/dalvikvm(12888): GC_CONCURRENT freed 28K, 50% free 3311K/6535K, external 1596K/2108K, paused 3ms+10ms
"My Object has been GC'd. " is printed by Packet's finalizer.
whole code: http://pastebin.com/zc5TcSgY
Why GS is removing my object? I've got in about 120 MB free memory.
How to fix it?

I think the problem is with oos because it might be the one causing NullPointerException.
Change your code a little as below:
System.out.println("Sending object..");
Packet p = new Packet(mJpegData); // here exists
System.out.println(p); // reference exists
if(oos != null)
oos.writeObject(p);
else
Log.w("oos", "its null");

Related

Process stopped unexpectedly on emulator when i run my application

I'm getting the process stopped unexpectedly on emulator when i run my application. Here are my logcat details:
06-30 15:09:46.126: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 46K, 53% free 2551K/5379K, external 1625K/2137K, paused 72ms
06-30 15:09:50.146: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 51ms
06-30 15:09:51.196: D/AndroidRuntime(520): Shutting down VM
06-30 15:09:51.196: W/dalvikvm(520): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:09:51.217: E/AndroidRuntime(520): FATAL EXCEPTION: main
06-30 15:09:51.217: E/AndroidRuntime(520): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.os.Looper.loop(Looper.java:123)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:09:51.217: E/AndroidRuntime(520): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520): at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:09:51.217: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:09:51.217: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:09:51.217: E/AndroidRuntime(520): at dalvik.system.NativeStart.main(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520): Caused by: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520): at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:09:51.217: E/AndroidRuntime(520): ... 11 more
06-30 15:09:54.516: I/Process(520): Sending signal. PID: 520 SIG: 9
06-30 15:17:01.117: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 48K, 53% free 2551K/5379K, external 1625K/2137K, paused 52ms
06-30 15:17:03.237: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 52ms
06-30 15:17:04.327: D/AndroidRuntime(539): Shutting down VM
06-30 15:17:04.327: W/dalvikvm(539): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:17:04.346: E/AndroidRuntime(539): FATAL EXCEPTION: main
06-30 15:17:04.346: E/AndroidRuntime(539): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.os.Looper.loop(Looper.java:123)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:17:04.346: E/AndroidRuntime(539): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539): at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:17:04.346: E/AndroidRuntime(539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:17:04.346: E/AndroidRuntime(539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:17:04.346: E/AndroidRuntime(539): at dalvik.system.NativeStart.main(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539): Caused by: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539): at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:17:04.346: E/AndroidRuntime(539): ... 11 more
06-30 15:17:08.717: I/Process(539): Sending signal. PID: 539 SIG: 9
Looking at the log
15:17:04.346: E/AndroidRuntime(539): Caused by:
java.lang.NullPointerException 06-30 15:17:04.346:
E/AndroidRuntime(539): at
com.mesha.firstand.firstl.onCreate(firstl.java:16)
you will see that a NullPointerException is thrown in line 16 of your activity firstl.
Please post your code of the firstl activity if you need more help on that.
as after seeing your logcat these maybe possible
CASE 1: make sure you are setting right layout:
public class firstl extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The activity is being created.
setContentView(R.layout.main);//MAKE SURE YOU ARE SETTING RIGHT LAYOUT
}
CASE 2: make sure you are using right id for views accessing in code as define in xml layout
CASE 3: make sure you are registering Activity with right name in Manifest.xml :
<Activity android:name=".firstl" />

Android SDK Emulator with OpenGL ES 2.0 Support?

recently while reading some tutorials online, I saw this video suggesting that the Android SDK now supports OpenGL ES 2.0:
http://www.youtube.com/watch?feature=player_embedded&v=T--vFtyZvc4
Enthusiastically, I added the option for 'GPU Emulation' in my emulator and tried to run a basic HelloOpenGLES20 app, however I was greeted with this error, and some null pointer exceptions which doesn't make sense:
Sorry!
The application
LessonOneActivity (process
lesson.One has stopped
unexpectedly. Please try again.
Force close
The app runs fine on a real Android phone displaying some spinning triangles, I'm wondering if anyone has encountered the problem I'm facing, I've did a fair share of googling but could find no solutions =(
Here's the log:
04-26 06:42:08.782: D/AndroidRuntime(577): Shutting down VM
04-26 06:42:08.813: W/dalvikvm(577): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-26 06:42:08.842: E/AndroidRuntime(577): FATAL EXCEPTION: main
04-26 06:42:08.842: E/AndroidRuntime(577): java.lang.RuntimeException: Unable to resume activity {lesson.One/com.learnopengles.android.lesson1.LessonOneActivity}: java.lang.NullPointerException
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2120)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.os.Handler.dispatchMessage(Handler.java:99)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.os.Looper.loop(Looper.java:130)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-26 06:42:08.842: E/AndroidRuntime(577): at java.lang.reflect.Method.invokeNative(Native Method)
04-26 06:42:08.842: E/AndroidRuntime(577): at java.lang.reflect.Method.invoke(Method.java:507)
04-26 06:42:08.842: E/AndroidRuntime(577): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-26 06:42:08.842: E/AndroidRuntime(577): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-26 06:42:08.842: E/AndroidRuntime(577): at dalvik.system.NativeStart.main(Native Method)
04-26 06:42:08.842: E/AndroidRuntime(577): Caused by: java.lang.NullPointerException
04-26 06:42:08.842: E/AndroidRuntime(577): at android.opengl.GLSurfaceView.onResume(GLSurfaceView.java:512)
04-26 06:42:08.842: E/AndroidRuntime(577): at com.learnopengles.android.lesson1.LessonOneActivity.onResume(LessonOneActivity.java:46)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.Activity.performResume(Activity.java:3832)
04-26 06:42:08.842: E/AndroidRuntime(577): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)
04-26 06:42:08.842: E/AndroidRuntime(577): ... 12 more
04-26 06:42:13.292: I/Process(577): Sending signal. PID: 577 SIG: 9
I have run the code, and the exception is due to the fact that the emulator still does not support GLES20. If you print more information, you'll see that supportsEs2 is false.
Why the emulator does not support GLES20 even if GPU Emulation is set to true is system-dependent. If you are developing on Linux, it may be related to the graphics card. Here is a similar question with some possible solutions. At least you can try it.
EDIT:
According to the official site, you need to set your emulator target to API 15 (rev03) or higher.

Android: How to load an image from gallery into the OpenCv Mat variable?

I'm currently try to run some opencv filters (i.e find egde, Median, ...) on images which are stored in the image gallery folder.
But I get error for loading image. My device is galaxy tab 10.1 with android 3.2, my opencv - API level 8.
I have the following source on a Button:
#Override
public void onClick(View v) {
Bitmap myBitmap = BitmapFactory.decodeFile("/sdcard/image1.jpg");
Bitmap myBitmap32 = myBitmap.copy(Bitmap.Config.ARGB_8888, true);
Mat pic1 = Utils.bitmapToMat(myBitmap32);
}
Here is LogCat:
02-07 12:31:27.290: I/System.out(16522): Not a DRM File, opening notmally
02-07 12:31:27.290: I/System.out(16522): buffer returned
02-07 12:31:27.310: D/dalvikvm(16522): GC_FOR_ALLOC freed 11K, 21% free 6975K/8775K, paused 19ms
02-07 12:31:27.320: I/dalvikvm-heap(16522): Grow heap (frag case) to 12.918MB for 6291472-byte allocation
02-07 12:31:27.340: D/dalvikvm(16522): GC_FOR_ALLOC freed <1K, 13% free 13119K/14983K, paused 19ms
02-07 12:31:27.380: D/dalvikvm(16522): GC_CONCURRENT freed 0K, 13% free 13119K/14983K, paused 2ms+2ms
02-07 12:31:27.710: D/dalvikvm(16522): GC_FOR_ALLOC freed 55K, 13% free 13063K/14983K, paused 20ms
02-07 12:31:27.730: I/dalvikvm-heap(16522): Grow heap (frag case) to 24.864MB for 12582928-byte allocation
02-07 12:31:27.780: D/dalvikvm(16522): GC_FOR_ALLOC freed 0K, 8% free 25351K/27335K, paused 21ms
02-07 12:31:27.830: D/dalvikvm(16522): GC_CONCURRENT freed <1K, 8% free 25351K/27335K, paused 2ms+3ms
02-07 12:31:27.890: W/dalvikvm(16522): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/android/Utils;
02-07 12:31:27.890: D/AndroidRuntime(16522): Shutting down VM
02-07 12:31:27.890: W/dalvikvm(16522): threadid=1: thread exiting with uncaught exception (group=0x400fc760)
02-07 12:31:27.890: E/AndroidRuntime(16522): FATAL EXCEPTION: main
02-07 12:31:27.890: E/AndroidRuntime(16522): java.lang.ExceptionInInitializerError
02-07 12:31:27.890: E/AndroidRuntime(16522): at photo.klu.PhotoKLUActivity$1.onClick(PhotoKLUActivity.java:82)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.view.View.performClick(View.java:3127)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.view.View$PerformClick.run(View.java:12025)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Handler.handleCallback(Handler.java:587)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Handler.dispatchMessage(Handler.java:92)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Looper.loop(Looper.java:132)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.app.ActivityThread.main(ActivityThread.java:4126)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.reflect.Method.invokeNative(Native Method)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.reflect.Method.invoke(Method.java:491)
02-07 12:31:27.890: E/AndroidRuntime(16522): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
02-07 12:31:27.890: E/AndroidRuntime(16522): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
02-07 12:31:27.890: E/AndroidRuntime(16522): at dalvik.system.NativeStart.main(Native Method)
02-07 12:31:27.890: E/AndroidRuntime(16522): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load opencv_java: findLibrary returned null
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.Runtime.loadLibrary(Runtime.java:425)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.System.loadLibrary(System.java:554)
02-07 12:31:27.890: E/AndroidRuntime(16522): at org.opencv.android.Utils.<clinit>(Utils.java:86)
02-07 12:31:27.890: E/AndroidRuntime(16522): ... 12 more
02-07 12:31:30.010: I/dalvikvm(16522): threadid=4: reacting to signal 3
02-07 12:31:30.010: I/dalvikvm(16522): Wrote stack traces to '/data/anr/traces.txt'
02-07 12:31:37.470: I/Process(16522): Sending signal. PID: 16522 SIG: 9
Any ideas?
Thank you.
The openCV library is not attached to your application. Please do the following (i assume that the openCV library is imported to your workspace). On Package Explorer > Right click on the application project > properties > under Library click Add > select openCV Be sure that on Java Build Path you don't have anything related to openCV

App force closes when returned back from the second activity to the first, the first activity no more works, has to be restarted again

I'm designing an application that allows the user to retrieve his data from the server, I'm furnishing this using two different activities, the first one receives the username as a text input and the second one displays the user's data based on the username. I'm using JSON schema for storing and retrieving the data. The app works fine for the first time but when I logout from the second screen using finish() and try to re-enter a new username in the first screen "the app force closes". This has been giving me sleepless nights, want to be overwhelmed with your support.
12-04 16:28:35.289: D/dalvikvm(553): GC_FOR_ALLOC freed 64K, 4% free 6893K/7171K, paused 64ms
12-04 16:28:35.299: I/dalvikvm-heap(553): Grow heap (frag case) to 7.757MB for 1000016-byte allocation
12-04 16:28:35.399: D/dalvikvm(553): GC_CONCURRENT freed 1K, 5% free 7868K/8199K, paused 16ms+3ms
12-04 16:28:35.529: D/dalvikvm(553): GC_FOR_ALLOC freed <1K, 5% free 7869K/8199K, paused 31ms
12-04 16:28:35.539: I/dalvikvm-heap(553): Grow heap (frag case) to 8.180MB for 443572-byte allocation
12-04 16:28:35.589: D/dalvikvm(553): GC_CONCURRENT freed 0K, 4% free 8302K/8647K, paused 3ms+5ms
12-04 16:28:35.889: D/gralloc_goldfish(553): Emulator without GPU emulation detected.
12-04 16:29:16.819: D/dalvikvm(553): GC_FOR_ALLOC freed 1079K, 14% free 7509K/8711K, paused 221ms
12-04 16:29:16.829: I/dalvikvm-heap(553): Grow heap (frag case) to 8.360MB for 1000016-byte allocation
12-04 16:29:16.889: D/dalvikvm(553): GC_CONCURRENT freed 2K, 3% free 8483K/8711K, paused 4ms+4ms
12-04 16:29:17.229: D/dalvikvm(553): GC_CONCURRENT freed 1016K, 13% free 7979K/9159K, paused 3ms+11ms
12-04 16:29:18.149: E/log_tag(553): Error parsing data org.json.JSONException: No value for Alert
12-04 16:29:20.949: D/dalvikvm(553): GC_CONCURRENT freed 274K, 12% free 8090K/9159K, paused 6ms+5ms
12-04 16:29:26.259: E/log_tag(553): Error parsing data org.json.JSONException: No value for Alert
12-04 16:29:26.859: D/AndroidRuntime(553): Shutting down VM
12-04 16:29:26.859: W/dalvikvm(553): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
12-04 16:29:26.929: E/AndroidRuntime(553): FATAL EXCEPTION: main
12-04 16:29:26.929: E/AndroidRuntime(553): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bombil.kustomizer/com.bombil.kustomizer.Menus}: java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.os.Looper.loop(Looper.java:137)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-04 16:29:26.929: E/AndroidRuntime(553): at java.lang.reflect.Method.invokeNative(Native Method)
12-04 16:29:26.929: E/AndroidRuntime(553): at java.lang.reflect.Method.invoke(Method.java:511)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-04 16:29:26.929: E/AndroidRuntime(553): at dalvik.system.NativeStart.main(Native Method)
12-04 16:29:26.929: E/AndroidRuntime(553): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
12-04 16:29:26.929: E/AndroidRuntime(553): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
12-04 16:29:26.929: E/AndroidRuntime(553): at java.util.ArrayList.get(ArrayList.java:304)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.AddEditText(Menus.java:309)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.AddInsertView(Menus.java:121)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.onCreate(Menus.java:88)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.Activity.performCreate(Activity.java:4465)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-04 16:29:26.929: E/AndroidRuntime(553): ... 11 more
12-04 16:29:27.009: D/dalvikvm(553): GC_CONCURRENT freed 273K, 10% free 8248K/9159K, paused 4ms+6ms
12-04 16:32:56.799: I/Process(553): Sending signal. PID: 553 SIG: 9
Apparently, you're trying to access an object in an ArrayList at in your Menus.java file at line 309. You're trying to access the object with the index of 2, but the total ArrayList size is only 2, meaning the highest index would be 1. This causes an IndexOutOfBounds exception as shown here:
ComponentInfo{com.bombil.kustomizer/com.bombil.kustomizer.Menus}:
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.AddEditText(Menus.java:309)
Do you have any objects that are being used by both activities? I know I saw this issue once with a project. One of the activities was messing up the HTTPClient object for the other activity. If you are getting a null exception being thrown try and find the variable. If it is a shared resource for both activities then just make sure to deal with it in a clean way when you exit the second activity.

Can't start ListActivity via Intent

I have 2 activities. First activity extends Activity and second extends ListActivity.
I need to call ListActivity from the Activity class
I have tried the following.
Intent intent = new Intent(firstclassname.this, secongclassname.class);
startActivity(intent);
I've added an entry in the manifest file but it doen't work.
That same code works for the Activity class (if the second class extends ListActivity)
I got following Logcat output
04-26 15:51:48.235: INFO/ActivityManager(52): Starting activity: Intent { cmp=android.com.testHTML/.FindFilesByType }
04-26 15:51:48.395: ERROR/ArrayAdapter(3113): You must supply a resource ID for a TextView
04-26 15:51:48.395: WARN/dalvikvm(3113): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
04-26 15:51:48.405: ERROR/AndroidRuntime(3113): Uncaught handler: thread main exiting due to uncaught exception
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:347)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.AbsListView.obtainView(AbsListView.java:1273)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.ListView.makeAndAddView(ListView.java:1658)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.ListView.fillDown(ListView.java:637)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.ListView.fillFromTop(ListView.java:694)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.ListView.layoutChildren(ListView.java:1516)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.AbsListView.onLayout(AbsListView.java:1112)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.view.View.layout(View.java:6569)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1108)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.LinearLayout.onLayout(LinearLayout.java:920)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.view.View.layout(View.java:6569)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.view.View.layout(View.java:6569)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.LinearLayout.onLayout(LinearLayout.java:918)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.view.View.layout(View.java:6569)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.view.View.layout(View.java:6569)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.view.ViewRoot.performTraversals(ViewRoot.java:979)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.view.ViewRoot.handleMessage(ViewRoot.java:1613)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.os.Handler.dispatchMessage(Handler.java:99)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.os.Looper.loop(Looper.java:123)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.app.ActivityThread.main(ActivityThread.java:4203)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at java.lang.reflect.Method.invokeNative(Native Method)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at java.lang.reflect.Method.invoke(Method.java:521)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at dalvik.system.NativeStart.main(Native Method)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): Caused by: java.lang.ClassCastException: android.widget.LinearLayout
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:340)
04-26 15:51:48.414: ERROR/AndroidRuntime(3113): ... 30 more
04-26 15:51:48.436: INFO/Process(52): Sending signal. PID: 3113 SIG: 3
04-26 15:51:48.446: INFO/dalvikvm(3113): threadid=7: reacting to signal 3
04-26 15:51:48.446: ERROR/dalvikvm(3113): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
04-26 15:51:58.289: WARN/ActivityManager(52): Launch timeout has expired, giving up wake lock!
04-26 15:51:58.289: WARN/ActivityManager(52): Activity idle timeout for HistoryRecord{4391c898 android.com.testHTML/.FindFilesByType}
What am I doing wrong?
Your activity is properly started.
The problem is in ArrayAdapter that you are using. You are not providing the resource id of the TextView.
Check out which constructor you are using and provide the correct parameters.

Categories

Resources