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. Conditionally Show View?

Hi,

I have a form which is used to edit an object and when adding the
object I want the user to be able to select from a Spinner, but after
saving I'd like to use the same View, but in place of the Spinner have
a TextView. Is there a conditional option in the xml so if no Spinner
is set up it shows the TextView instead (and vice-versa)?

Sorta like:
<ListView android:id="@+id/android:list"
          android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
<TextView android:id="@+id/android:empty"
          android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="No Services Configured..."/>

In this case if the list is empty then the TextView shows... (at least
I think that's how it works :))

(BTW - I posted this about 13 hours ago in android-beginners and it
didn't turn up so I'm posting again. My apologies if it turns up
twice.)

Cheers,
Julius.
--~--~---------~--~----~------------~-------~--~----~

2. Error when I try to running Android application into Netbeans 6.5

Dear friends,

I installed recently Android plug-in in my NetBeans IDE 6.5 (MS-
Windows Vista) but when I try to run any application I received the
error, under:

   init:
   deps-jar:
   Compiling 1 source file to C:\Downloads\Android\HelloDroid\build
\classes
   compile:
   Updating jar: C:\Downloads\Android\HelloDroid\dist\HelloDroid.apk_
   Updating zip: C:\Downloads\Android\HelloDroid\dist\HelloDroid.apk_
   Failed to create 'dist/HelloDroid.apk' : The system cannot find the
   path specified
   C:\Downloads\Android\HelloDroid\nbproject\build-impl.xml:436: exec
   returned: 1
   FALHA NA CONSTRUO (tempo total: 8 segundos)

Anybody know what happens?

Thanks,

Andre Barrozo
--~--~---------~--~----~------------~-------~--~----~

3. Driving Directions using Google Map APIs

4. Can't open /dev/ttyVSP0 in mainloop() which located in reference-ril.c,why???????

5. BUG: Android Asset Packaging Tool (aapt) crash

6. BUG: Android Asset Packaging Tool (aapt) crash

7. How to detect the state change of Bluetooth?