Exemple #1
0
  /**
   * 运行 service 的缺省实现
   *
   * @param t
   * @param arg
   * @return
   * @throws NoSuchMethodException
   * @throws SecurityException
   */
  protected final boolean runService(Context t, ServiceThread srvOwner) {
    boolean ret = true;

    try {
      if (srvOwner != null && !StringUtil.isNullOrEmpty(srvOwner.getDelegate())) {
        String serviceDelegate = srvOwner.getDelegate();

        Method m = this.getClass().getMethod(serviceDelegate, Object[].class);

        if (m != null) {
          m.invoke(this, srvOwner.getArgs());
        }

        ret = true;
      }
    } catch (Exception ex) {
      throw new RuntimeException("runService error.", ex);
    }
    return ret;
  }