Many parts of the fetus brain begin showing neural activity before the senses that feed them are sufficiently developed to provide actual sensory information. In other words, it is unlikely that spiking activity in the brain is initiated by the senses. Some of the cells that become sensory organs, however, often fire in very specific patterns similar to the patterns they will use when they start actually sensing.
An example from Penn & Shatz (1999): in the human fetus, the connections from the eye to the visual cortex form before the retina is developed enough to respond to light. However, at this time the retinal ganglion cells spontaneously generate highly correlated bursts of action potentials. These bursts are similar to the sort of data they will generate once they actual start sensing, and these preliminary bursts allow the human fetus to start developing its visual cortex before it even has functional retina. This is not unique to humans, and similar activity was first observed in rats (Galli & Maffei, 1988).
The take away message, is that the cell in the brain start firing spontaneously before they has any sensory input. Some of this early firing is 'random' in the sense you asked before. However, neurons that develop into future sensory organs, tend to have their spontaneous firing resemble what their typical sensory production will look like in the future (once they start sensing). This allows the downstream circuitry to start adapting to the firing pattens before any real sensory infromation becomes available.
References