private void openGPSSettings()
{
LocationManager alm = (LocationManager)this.getSystemService( Context.LOCATION_SERVICE );
if( alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER ) )
{
Toast.makeText( this, "GPS is already on", Toast.LENGTH_SHORT ).show();
}
else
{
Toast.makeText( this, "Please turn on GPS", Toast.LENGTH_SHORT ).show();
Intent myIntent = new Intent( Settings.ACTION_SECURITY_SETTINGS );
startActivity(myIntent);
}
}
本文提供了一个简单的Android代码示例,用于检查当前设备的GPS是否已启用,并在未启用时引导用户前往GPS设置页面进行开启。
4038

被折叠的 条评论
为什么被折叠?



