2012-10-17 44 views
7

当我在这行代码:“未捕获的异常被终结抛出”打开MapActivity

// create tab4 
intent = new Intent(this, ActWhereAmI.class) 
     .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
tabspecWhereAmI = tabHost 
     .newTabSpec("tab4") 
     .setIndicator(Utilities.prepareTabView(this,"where am I")) 
     .setContent(intent); 
tabHost.addTab(tabspecWhereAmI); 


public static View prepareTabView(Context context, String text) { 
     View view = LayoutInflater.from(context).inflate(
       R.layout.tab_indicator, null); 
     TextView tv = (TextView) view.findViewById(R.id.tabIndicatorTextView); 
     tv.setText(text); 

     return view; 
    } 

当应用程序运行线路tabHost.addTab(tabspecWhereAmI);我收到以下错误只在logcat中,程序没有任何问题运行:的ActWhereAmIonCreate(...)方法之前发生

10-17 13:38:01.164: W/MapActivity(4815): Recycling dispatcher android_maps_conflict_a[email protected]413c8658 
10-17 13:38:01.171: V/MapActivity(4815): Recycling map object. 
10-17 13:38:01.335: W/MapActivity(4815): Recycling dispatcher android_maps_conflict_a[email protected]413c8658 
10-17 13:38:01.335: V/MapActivity(4815): Recycling map object. 
10-17 13:38:01.554: D/dalvikvm(4815): GC_CONCURRENT freed 776K, 23% free 10286K/13255K, paused 2ms+7ms 
10-17 13:38:01.554: E/System(4815): Uncaught exception thrown by finalizer 
10-17 13:38:01.554: E/System(4815): java.lang.IllegalStateException: Binder has been finalized! 
10-17 13:38:01.554: E/System(4815):  at android.os.BinderProxy.transact(Native Method) 
10-17 13:38:01.554: E/System(4815):  at android.database.BulkCursorProxy.close(BulkCursorNative.java:288) 
10-17 13:38:01.554: E/System(4815):  at android.database.BulkCursorToCursorAdaptor.close(BulkCursorToCursorAdaptor.java:133) 
10-17 13:38:01.554: E/System(4815):  at android.database.CursorWrapper.close(CursorWrapper.java:49) 
10-17 13:38:01.554: E/System(4815):  at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:1591) 
10-17 13:38:01.554: E/System(4815):  at android.content.ContentResolver$CursorWrapperInner.finalize(ContentResolver.java:1604) 
10-17 13:38:01.554: E/System(4815):  at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182) 
10-17 13:38:01.554: E/System(4815):  at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168) 
10-17 13:38:01.554: E/System(4815):  at java.lang.Thread.run(Thread.java:856) 
10-17 13:38:01.554: E/System(4815): Uncaught exception thrown by finalizer 
10-17 13:38:01.554: E/System(4815): java.lang.IllegalStateException: Binder has been finalized! 
10-17 13:38:01.554: E/System(4815):  at android.os.BinderProxy.transact(Native Method) 
10-17 13:38:01.554: E/System(4815):  at android.database.BulkCursorProxy.close(BulkCursorNative.java:288) 
10-17 13:38:01.554: E/System(4815):  at android.database.BulkCursorToCursorAdaptor.close(BulkCursorToCursorAdaptor.java:133) 
10-17 13:38:01.554: E/System(4815):  at android.database.CursorWrapper.close(CursorWrapper.java:49) 
10-17 13:38:01.554: E/System(4815):  at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:1591) 
10-17 13:38:01.554: E/System(4815):  at android.content.ContentResolver$CursorWrapperInner.finalize(ContentResolver.java:1604) 
10-17 13:38:01.554: E/System(4815):  at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182) 
10-17 13:38:01.554: E/System(4815):  at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168) 
10-17 13:38:01.554: E/System(4815):  at java.lang.Thread.run(Thread.java:856) 

此异常。我的问题类似于这个问题:Uncaught exception thrown by finalizer

为什么我得到这个错误,我该如何解决它?

+0

什么是'Utilities.prepareTabView()'方法的主体? – krtek

+0

是您的活动MapActivity?也许它与您使用的MapActivity相关,与您发布的代码无关 – nandeesh

+0

@nandeesh yesy它是一个MapActivity。 – breceivemail

回答

4

你是否在做任何与数据库相关的事情?它几乎听起来像是做数据库事件的活动关闭了游标(手动或自动),然后尝试在finalize()中执行某些操作,或者游标正在被Android OS关闭。

在情况#2中,这可能意味着您可能必须手动关闭游标。如果是这种情况,但如果您需要打开活动,请考虑在onResume/onPause或onStart/onStart上重新打开/关闭它

其他人提到可能是因为您试图同时打开其中两个

1

这在某种程度上与CursoronStop()onDestroy()有关。你可以调用closeTab()closeAllTabs()来调用它。

希望这会有所帮助。

1

在应用程序遍历另一个活动之前,请记住在完成游标后关闭游标。