开发者

How to test a TabActivity extended class without running into exceptions when adding tabs?

开发者 https://www.devze.com 2023-04-05 17:33 出处:网络
I\'m getting the following trace: java.lang.NullPointerException at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:277)

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号