Here is the solution.
Be sure to "set" the "handle" on the zipper by pressing it firmly against the zipper. If this doesn't solve the problem, there's more than likely a problem with the fit of the jeans that causes this, i.e., they bulge at the wrong spot in the front, perhaps when you sit, allowing the "latch" on the zipper to flip up and unzip itself. If this is the case, just get rid of them; you'll not be able to keep them zipped. A solution is to get a large safety pin and on the inside of the jeans, place the pin across the zipper just under the slide part. This won't show if you do it properly but it won't allow the slide to move either. However, don't get in a situation where you don't have time to remove the safety pin in the restroom!