Esempio n. 1
0
  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;
    }
  }
Esempio n. 2
0
  /**
   * [初始化服务]<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);

  }
Esempio n. 3
0
 @Override
 public void onServiceConnected(ComponentName name, IBinder service) {
   notificationService = ((NotificationServiceBinder) service).getService();
   if (notificationCallback != null) {
     notificationCallback.doStuff();
   }
   //			String deviceId = DeviceInfoUtil.getDeviceId(Application.this);
   String token = PushUtil.createMD5Token(Application.this);
   loginXmppClient(token, token, notificationService.getPushManager());
 }
Esempio n. 4
0
  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);
    }
  }