2013-04-24 69 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回調。