The GPS receiver cannot be turned on or off with App Inventor 2 with code Blocks nor can it be turned on or off with any other compiler like Android Studio. Google does not allow this.
You can bring up this screen (or a similar one depending on the Android operating system) using an ActivityStarter in the app..
Once the screen displays from the device's Settings, the USER can manually turn on and off the GPS receiver from that screen.
You can also set the LocationSensor1.Enabled to true or false to 'turn on or off' (that is prevent) the Location sensor from displaying current location information. However that does not turn on or off the GPS receiver.
Is this what you wanted to know Stefano?