2013-04-24 66 views
0

叫我使用绑定到我的所有activities本地Service,当我开始一个Activity我得到一个callback绑定的服务onServiceConnected回调不TabHost

@Override 
     public void onServiceConnected(ComponentName name, IBinder service) { 
} 

,但如果我用一个TabHost并且如果活动正在以下一个方式开始:

TabSpec spec = tabHost.newTabSpec("Spec"); 
intent = new Intent(this, TestActivity.class); 
spec.setContent(intent); 

onServiceConnected回调被neved调用。

为什么?如何解决这种情况?

SUMMARY: 

intent = new Intent(this, MyActivity.class); 
startActivity(intent); // In this case callback is called 


TabSpec spec = tabHost.newTabSpec("Spec"); 
intent = new Intent(this, MyActivity.class); 
spec.setContent(intent); // In this case callback is not called 
+0

发布一些更多的代码,这是不够的解决方案 – stackoverflow 2013-04-24 10:44:53

回答

0

在标签而非bindService(.....)你必须按顺序使用getApplicationContext.bindService(.....)的是撞到了onServiceConnected回调。