This is another very common question as it would make sense for this to be the case, but sadly it is not the case. As of July 13th, the game does not do anything to track your distance traveled while the game is not running as the primary app. When you turn the game off for a period of time and start it back up, it does seem like the game remained running and your character will begin running to your new location. The distance that the character travels in this time does not count toward your distance travelled.
There is a battery saver mode that will turn off the screen when the screen is turned upside down. This will allow you to track distance and conserve some battery. If you are looking to use other apps while out for a walk and expect the distance to be tracked, you will have to wait and see if the game developer decides to release an update for the game to allow for this.