How do I find out if the GPS of an Android device is enabled

后端 未结 10 1564
暖寄归人
暖寄归人 2020-11-22 08:36

On an Android Cupcake (1.5) enabled device, how do I check and activate the GPS?

10条回答
  •  难免孤独
    2020-11-22 09:01

    This piece of code checks GPS status

    final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE );
    if ( !manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
        buildAlertMessageNoGps();
    }
    

    `

提交回复
热议问题