Obtaining accurate parameters, state of charge (SoC) and capacity of a lithium-ion battery is crucial for a battery management system, and establishing a battery model online is complex. In addition, the errors and perturbations of the battery model dramatically increase throughout the battery lifetime, making it more challenging to model the battery online. To overcome these difficulties, this paper provides three contributions: (1) To improve the robustness of the adaptive particle filter algorithm, an error analysis method is added to the traditional adaptive particle swarm algorithm. (2) An online adaptive SoC estimator based on the improved adaptive particle filter is presented; this estimator can eliminate the estimation error due to battery degradation and initial SoC errors. (3) The effectiveness of the proposed method is verified using various initial states of lithium nickel manganese cobalt oxide (NMC) cells and lithium-ion polymer (LiPB) batteries. The experimental analysis shows that the maximum errors are less than 1% for both the voltage and SoC estimations and that the convergence time of the SoC estimation decreased to 120s.