How to programmatically enable GPS in Android Cupc

2019-01-03 14:56发布

I'm currently writing an app in Android that works with the GPS. At the moment I'm able to work out whether the GPS is enabled. My problem is that I want to enable the GPS on app startup if it is disabled. How can I do this programmaticaly?

7条回答
爷的心禁止访问
2楼-- · 2019-01-03 15:48
if(!LocationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER ))
{
    Intent myIntent = new Intent( Settings.ACTION_SECURITY_SETTINGS );
    startActivity(myIntent);
}
查看更多
登录 后发表回答