文件名称: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); //此为设置完成后返回到获取界面 } ......