/** * [初始化服务]<br> * [功能详细描述] 2013-7-16 上午11:53:16 */ private void initServices() { stopService(NotificationService.getIntent(this)); this.bindService( ModuleOperationService.getIntent(this), moduleServiceConnection, Context.BIND_AUTO_CREATE); this.bindService( NotificationService.getIntent(this), notificationServiceConnection, Context.BIND_AUTO_CREATE); // this.bindService(new Intent(this, MinaPushService.class), // minaServiceConnection, Context.BIND_AUTO_CREATE); }
public XmppManager getPushManager() { if (null != notificationService) { return notificationService.getPushManager(); } else { // String username = Preferences.getUserName(Application.sharePref); // loginChatClient(username, username); Log.e( "notificationService====", "notificationServiceConnection=" + notificationServiceConnection); Log.e("notificationService====", "BeforeBindnotificationService=" + notificationService); this.bindService( NotificationService.getIntent(this), notificationServiceConnection, Context.BIND_AUTO_CREATE); loginXmppClient( Preferences.getUserName(Application.sharePref), Preferences.getUserName(Application.sharePref), notificationService.getPushManager()); Log.e("notificationService====", "AffterBindnotificationService=" + notificationService); if (notificationService != null) { return notificationService.getPushManager(); } return null; } }
public void loginXmppClient( final String username, final String password, final XmppManager manager) { if (notificationService == null) { this.bindService( NotificationService.getIntent(this), notificationServiceConnection, Context.BIND_AUTO_CREATE); notificationCallback = new NotificationCallback() { @Override public void doStuff() { notificationService.connect(username, password, manager); } }; } else { notificationService.connect(username, password, manager); } }