How to test a TabActivity extended class without running into exceptions when adding tabs?
I'm getting the following trace:
java.lang.NullPointerException
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:277)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
at android.widget.TabHost.setCurrentTab(TabHost.java:323)
at android.widget.TabHost.addTab(TabHost.开发者_开发百科java:213)
....
My code:
Intent intent = new Intent(getInstrumentation().getTargetContext(), TabbedView.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityInfo info = new ActivityInfo();
Activity father = new Activity();
TabbedView activity = (TabbedView) getInstrumentation().
newActivity(TabbedView.class, getInstrumentation().getTargetContext(), null, null, intent, info,
TabbedView.class.getName(), father, null, null);
TabbedView
extends from TabActivity
and inner to TabbedView.onCreate()
a call to TabHost.addTab()
is issued.
Has anyone found a way to solve this problem? Testing TabActivity
is usually a problem.
Thanks.
精彩评论