【文件属性】:
文件名称:Android GPS定位
文件大小:75KB
文件格式:DOC
更新时间:2015-07-08 11:43:32
Android 定位 GPS
多种GPS定位方式和定位研究开发心得,提供了百度定位 和 谷歌定位两种方式,基站、wifi、net定位。
google定位代码
package com.javenwong.google_gps;
import android.app.Activity;import android.content.Context;import android.content.Intent;import android.location.Criteria;import android.location.Location;import android.location.LocationListener;import android.location.LocationManager;import android.os.Bundle;import android.widget.TextView;import android.widget.Toast;
public class Google_gpsActivity extends Activity { TextView tv1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent i = new Intent(this, ServiceTest.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startService(i);
tv1 = (TextView) this.findViewById(R.id.tv1); openGPSSettings();// String ip=GetHostIp();// tv1.setText(ip);// Log.i("hello", "ip is"+ip); // getLocation(); //tv1.setText(ip); tv1.setText("hello"); } private void openGPSSettings() { LocationManager alm = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); if (alm .isProviderEnabled(android.location.LocationManager.NETWORK_PROVIDER)) { Toast.makeText(this, "Net模块正常", Toast.LENGTH_SHORT) .show(); return; }
Toast.makeText(this, "请开启GPS!", Toast.LENGTH_SHORT).show();// Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);// startActivityForResult(intent,0); //此为设置完成后返回到获取界面
}
......
网友评论
- 完美的解决了我的问题
- 改一改 用起来 定位很准确
- 不是dome,只是代码
- 要修改才能用,还是很有参考价值!
- 学习怎么用gps定位
- 不错,用得上!
- 认识一下google的定位使用方法
- 要修改才能用,还是很有参考价值!
- 不错~~还是挺有用的
- 要修改才能用,还是很有参考价值!
- 不错的实力代码
- 资料还是有参考价值的 不错
- 现在用的是百度提供的接口,但是这个也有参考价值,谢谢楼主的分享。。
- 很好的demo,有用
- 不错的实例代码
- 没用,获取不到
- 不错的代码。。。
- 不错的实例代码。
- 网络不好就定不了位,百度定位非常不错
- 不错,定位得到