Most of the "don't text while diving" apps use GPS to determine if the person is in motion at speeds that resemble those of a car. That means those riding buses as passengers can be prevented from communications. But, more contest sensitive apps are in the works:
Researchers at Pacific Northwest National Laboratory (PNNL) are studying how software on a cell phone could analyze keystrokes to determine when that phone’s user is distracted while composing and sending text messages. This doesn’t necessarily mean the person is driving, of course, but combined with GPS and other data, it may be possible to determine when a texter is behind the wheel. In that case, the phone could shut off texting functions automatically. Such a feature could take the form of a mobile app for any phone—independent of the manufacturer, operating system and wireless service provider.
It turns out undistracted texting has a rhythmic patter while distracted texting is more chaotic.