Binding Services Quick Question
SO I am trying to bind a service with my application a开发者_如何学Gond I was wondering if its possible to bind that to every single activity (one service to 10 activities).
Thanks, Arber
Yes, you should in fact be using the same code in each Activity:
public class YourActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bindService(new Intent(), new ServiceConnection(){
@Override
public void onServiceConnected(ComponentName arg0, IBinder arg1) {
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
}
}, Context.BIND_AUTO_CREATE);
}
}
精彩评论