2

我有一个我支持的 android 应用程序,在多次调用其中一个活动后,它在尝试从意图中获取额外内容时会引发 stackoverflowerror。这是崩溃时的堆栈跟踪。关于为什么在下一次调用活动至少 4 次后从意图中获取额外内容时抛出 StackOverflowError 的任何想法?

用于构建意图的代码包含 String、String、boolean、Object:

Intent videoIntent = new Intent(this, VideoPlayer.class);
videoIntent.putExtra(AppNames.EXTRA_VIDEO_URI, uri);
videoIntent.putExtra(AppNames.EXTRA_VIDEO_TITLE, channel.getName());
videoIntent.putExtra(AppNames.EXTRA_VIDEO_MODE_RESUME, false);
videoIntent.putExtra(AppNames.EXTRA_MCD_CHANNEL, channel);
startActivity(videoIntent);  

并且抛出 StackOverflowError 的代码是:
uri = getIntent().getStringExtra(AppNames.EXTRA_VIDEO_URI);

I/dalvikvm( 1719): Stack overflow, expanding (0x41048200 to 0x41048000)  
I/dalvikvm( 1719): Shrank stack (to 0x41048200, curFrame is 0x4104834c)  
D/AndroidRuntime( 1719): Shutting down VM  
W/dalvikvm( 1719): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)  
E/AndroidRuntime( 1719): Uncaught handler: thread main exiting due to uncaught exception  
E/AndroidRuntime( 1719): java.lang.StackOverflowError  
E/AndroidRuntime( 1719):  at java.lang.reflect.ReflectionAccessImpl.clone(ReflectionAccessImpl.java:38)  
E/AndroidRuntime( 1719):  at java.lang.Class.getDeclaredMethod(Class.java:765)  
E/AndroidRuntime( 1719):  at java.io.ObjectStreamClass.getPrivateReadObjectMethod(ObjectStreamClass.java:789)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1525)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1455)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2124)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:956)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2289)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2243)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1296)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:545)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1549)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1455)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2124)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:956)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2289)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2243)  
E/AndroidRuntime( 1719):  at java.util.ArrayList.readObject(ArrayList.java:702)  
E/AndroidRuntime( 1719):  at java.lang.reflect.Method.invokeNative(Native Method)  
E/AndroidRuntime( 1719):  at java.lang.reflect.Method.invoke(Method.java:521)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1534)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1455)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2124)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:956)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2289)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2243)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1296)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:545)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1549)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1455)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2124)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:956)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2289)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2243)  
E/AndroidRuntime( 1719):  at java.util.ArrayList.readObject(ArrayList.java:702)  
E/AndroidRuntime( 1719):  at java.lang.reflect.Method.invokeNative(Native Method)  
E/AndroidRuntime( 1719):  at java.lang.reflect.Method.invoke(Method.java:521)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1534)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1455)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2124)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:956)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2289)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2243)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1296)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:545)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1549)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1455)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2124)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:956)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2289)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2243)  
E/AndroidRuntime( 1719):  at java.util.ArrayList.readObject(ArrayList.java:702)  
E/AndroidRuntime( 1719):  at java.lang.reflect.Method.invokeNative(Native Method)  
E/AndroidRuntime( 1719):  at java.lang.reflect.Method.invoke(Method.java:521)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1534)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1455)  
E/AndroidRuntime( 1719):  at java.io.ObjectInputStream.readNew  
D/dalvikvm( 1719): GC freed 6315 objects / 501704 bytes in 154ms  
I/Process (   56): Sending signal. PID: 1719 SIG: 3  
I/dalvikvm( 1719): threadid=7: reacting to signal 3  
4

2 回答 2

1

您的对象看起来太复杂了。当你序列化一个对象时,它的内容必须被序列化。如果它包含其他对象,则这些对象也必须反序列化,等等。

于 2010-01-25T17:12:18.670 回答
1

据我所知,getIntent().getStringExtra()返回一个字符串而不是 URI。

于 2010-09-28T12:20:00.407 回答