开发者

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);
}
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜