With the development of location-based service (LBS), indoor positioning based on pedestrian dead reckoning (PDR) has become a hot research topic. Smartphones are becoming more popular for indoor positioning. This paper proposes a two-step robust-adaptive-cubature Kalman filter (RACKF) algorithm based on smartphone micro-electro-mechanical-system (MEMS) sensor fusion for indoor positioning. To estimate pedestrian heading, a quaternion-based robust-adaptive-cubature Kalman filter algorithm is proposed. Firstly, the model noise parameters are adaptively corrected based on the fading-memory-weighting method and the limited-memory-weighting method. The memory window of the limited-memory-weighting algorithm is modified based on the characteristics of pedestrian walking. Secondly, an adaptive factor is constructed based on the partial state inconsistency to overcome filtering-model deviation and abnormal disturbances. Finally, to identify and control the measurement outliers, the robust factor based on maximum-likelihood estimation is introduced into the filtering to enhance the robustness of heading estimation and support more robust dynamic-position estimation. In addition, based on the accelerometer information, a nonlinear model is constructed and the empirical model is used to estimate the step length. Combining heading and step length, the two-step robust-adaptive-cubature Kalman filter is proposed to improve the pedestrian-dead-reckoning method, which enhances the adaptability and robustness of the algorithm and further improves the accuracy of the plane-position solution. The adaptive factor based on the prediction residual and the robust factor based on the maximum-likelihood estimation are introduced into the filter to improve the adaptability and robustness of the filter, reduce the positioning error, and improve the accuracy of the pedestrian-dead-reckoning method. Three different smartphones are used to validate the proposed algorithm in an indoor environment. Additionally, the experimental results confirm the algorithm’s effectiveness. From the results of the three smartphones, the root mean square error (RMSE) of the indoor-positioning results obtained by the proposed method is about 1.3–1.7 m.