我想在我的应用程序启动时启用 GPS 30 秒(当 oncreate() 方法调用时)。并在 30 秒后转为禁用模式。
1034 次
2 回答
8
试试这个代码,
LocationManager locationManager =(LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, WLConstants.DELAY_HOUR, gpsl
.getMinDistance(), gpsl);
并停止 GPS 尝试
locationManager.removeUpdates(gpsl);
在你完成你的时间段后给这个。
于 2011-06-20T12:16:38.723 回答
0
try this code
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
1,
0,
myLocationListener
);
于 2011-06-20T12:22:55.163 回答