Example #1
0
 /** * Stop location service */
 @Override
 protected void onStop() {
   // TODO Auto-generated method stub
   locationService.unregisterListener(mListener); // 注销掉监听
   locationService.stop(); // 停止定位服务
   super.onStop();
 }
Example #2
0
 @Override
 protected void onStart() {
   // TODO Auto-generated method stub
   super.onStart();
   // -----------location config ------------
   locationService = ((LocationApplication) getApplication()).locationService;
   // 获取locationservice实例,建议应用中只初始化1个location实例,然后使用,可以参考其他示例的activity,都是通过此种方式获取locationservice实例的
   locationService.registerListener(mListener);
   // 注册监听
   int type = getIntent().getIntExtra("from", 0);
   if (type == 0) {
     locationService.setLocationOption(locationService.getDefaultLocationClientOption());
   } else if (type == 1) {
     locationService.setLocationOption(locationService.getOption());
   }
   locationService.start();
 }