Exception when clearing tabs and onResume() from different applications

by Miguel Paraz » Thu, 10 Dec 2009 00:33:18 GMT


Sponsored Links
 i,
In my onResume() I have this, to recreate the tabs every time i run.
This is because the tab content changes depending on the program
state.

tabHost = getTabHost();
tabHost.setCurrentTab(0);
tabHost.clearAllTabs();
tabSpec = tabHost.newTabSpec("Label");
tabSpec.setContent(new Intent(this, ContentActivity.class));
// more tabs...

This works within the same application.
But when an external application is launched, or if the phone returns
from idle, this happens. It looks like an internal loop or race
condition. Is there a better way to rebuild the TabHost? This is on
Cupcake.

12-09 18:55:47.596 E/AndroidRuntime( 1009): Caused by:
java.lang.NullPointerException
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.widget.TabWidget.onFocusChange(TabWidget.java:241)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.View.onFocusChanged(View.java:2430)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.View.handleFocusGainInternal(View.java:2258)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.handleFocusGainInternal(ViewGroup.java:398)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.View.requestFocus(View.java:3232)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.requestFocus(ViewGroup.java:1005)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:
1050)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.requestFocus(ViewGroup.java:1009)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:
1050)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.requestFocus(ViewGroup.java:1006)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:
1050)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.requestFocus(ViewGroup.java:1006)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:
1050)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.requestFocus(ViewGroup.java:1006)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.View.requestFocus(View.java:3183)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewRoot.clearChildFocus(ViewRoot.java:1378)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.clearChildFocus(ViewGroup.java:501)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.clearChildFocus(ViewGroup.java:501)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.clearChildFocus(ViewGroup.java:501)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.clearChildFocus(ViewGroup.java:501)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.clearChildFocus(ViewGroup.java:501)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:2204)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.view.ViewGroup.removeAllViews(ViewGroup.java:2150)
12-09 18:55:47.596 E/AndroidRuntime( 1009): at
android.widget.TabHost.clearAllTabs(TabHost.java:214)
12-09 18:55:47.596 E/AndroidRuntime



Other Threads

1. Join Thailand Forums Thailand Message Boards Living, Work and Play in Thailand ...X.

Join Thailand Forums
Thailand Message Boards Living, Work and Play in Thailand 
http://www.poetak.blogspot.com


-- 

2. Join Thailand Forums Thailand Message Boards Living, Work and Play in Thailand ...W.

Join Thailand Forums
Thailand Message Boards Living, Work and Play in Thailand 
http://www.poetak.blogspot.com


-- 

3. AutoText di Android (bahasa Indonesia)

4. Dev Phone 1 suddenly died -- will not charge, completely dark

5. TEST from my 1st N1

6. OOT Nx1 2nd

7. Enable Multitouch in Nexus One Web Browser