android gps定位app源码(GpsTracker)

电脑杂谈  发布时间:2020-01-06 20:02:33  来源:网络整理

android gps开发_android gps开发_gps设备开发

【实例简介】做到了 gps 开启关闭后的提醒 以及地理位置记录(经纬度)

gps设备开发_android gps开发_android gps开发

【实例截图】

android gps开发_android gps开发_gps设备开发

from clipboard

android gps开发_android gps开发_gps设备开发

【核心代码】

android gps开发_gps设备开发_android gps开发

package android.gpstracker;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;
public class GPSTracker extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		/* Use the LocationManager class to obtain GPS locations */
		LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
		LocationListener mlocListener = new MyLocationListener();
		mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
	}
	public class MyLocationListener implements LocationListener {
		public void onLocationChanged(Location loc) {
			loc.getLatitude();
			loc.getLongitude();
			String Text = "My current location is: "   "Latitude = "   loc.getLatitude()   " Longitude = "   loc.getLongitude();
			Toast.makeText(getApplicationContext(), Text, Toast.LENGTH_SHORT).show();
		}
		public void onProviderDisabled(String provider) {
			Toast.makeText(getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT).show();
		}
		public void onProviderEnabled(String provider) {
			Toast.makeText(getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show();
		}
		public void onStatusChanged(String provider, int status, Bundle extras)
		{
		}
	}
}

不能下载?内容有错android gps开发android gps开发? 点击此处报错 + 投诉 + 提问


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/shumachanpin/article-136001-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      • 温镗
        温镗

        #宋茜#

      • 杜鹏鹏
        杜鹏鹏

        要是美帝能保证伊国领土不被伊凡份子攻占

      热点图片
      拼命载入中...