2013年7月14日 20:50:54

来源:互联网 发布:广联达造价软件下载 编辑:程序博客网 时间:2024/06/16 06:09



0714


android的学习接近尾声?
然后是总结和复习,利用思维导图把我们android所有的东西总结下来,理出一条线
组件,API,等。3天,下周三,IMindMap,
--------------
通过Web Service进行网络编程,是在互联网上可调其他的远程,跟语言、平台无关,
传输协议【SOAP】,Simple Object Access Protocol简单对象访问协议,请求的是HTTP,发送和接收的是SOAP协议,
Web服务器描述语言【WSDL】,Web Service Description Language,XML文件(⊙o⊙)


城市天气,服务,电子书上。
---------------
十六章Android中的GPS应用
copy【TestLocationActivity】代码


--------【记住导自己的过程】,有道笔记是什么?云储存?
明天,传感器


 个很怀念的名词呢~

/** * 测试location界面 *  * @author Administrator *  */public class TestLocationActivity extends Activity implements OnClickListener, LocationListener {private TextView showProviderView;private LocationManager locationManager;private Location location;private Button getProviderBtn,addProviderBtn;private TextView showEditText;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.activity_test_location_);getProviderBtn = (Button) findViewById(R.id.test_loaction_main_btn_getprovider);addProviderBtn=(Button) findViewById(R.id.test_loaction_main_btn_addPoint);showProviderView = (TextView) findViewById(R.id.test_loaction_main_tv_showlocation);showEditText=(TextView) findViewById(R.id.test_loaction_main_tv_show);// 获取定位管理器locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);getProviderBtn.setOnClickListener(this);addProviderBtn.setOnClickListener(this);////注册跟踪位置的监听器//locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 1, new LocationListener() {//public void onStatusChanged(String provider, int status, Bundle extras) {//}////当provider能够使用的时候调用//public void onProviderEnabled(String provider) {//getLocationInfo(locationManager.getLastKnownLocation(provider));//}//public void onProviderDisabled(String provider) {//}////当位置发生改变时调用//public void onLocationChanged(Location location) {//getLocationInfo(location);//}//});}@Overrideprotected void onResume() {super.onResume();locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 1, this);}@Overrideprotected void onPause() {// TODO Auto-generated method stubsuper.onPause();locationManager.removeUpdates(this);}@Overridepublic void onClick(View v) {if (v == getProviderBtn) {// 获取所有的定位方式List providerList = locationManager.getAllProviders();StringBuffer sb = new StringBuffer();sb.append("获取所有的定位方式:" + providerList + "\n");// 获取可用的定位方式List enableProviderList = locationManager.getProviders(true);sb.append("获取可用的定位方式:" + enableProviderList + "\n");// 根据条件或定位方式Criteria criteria = new Criteria();criteria.setCostAllowed(true);// 获取免费的定位方式criteria.setAltitudeRequired(true);// 获取能够提供高度的定位方式criteria.setBearingRequired(true);// 获取能够提供方向的定位方式List criteriaProviderList = locationManager.getProviders(criteria,true);sb.append("获取根据条件过滤的定位方式:" + criteriaProviderList + "\n");// 通过获取的定位方式来得到定位信息if (criteriaProviderList.contains(LocationManager.GPS_PROVIDER)) {location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);} else if (criteriaProviderList.contains(LocationManager.NETWORK_PROVIDER)) {location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);}String locationStr = getLocationInfo(location);sb.append("位置信息:\n" + locationStr);}if (v==addProviderBtn) {double latitude=40;//纬度double longitude=50;//经度float radius=10000;//半径10kmlong expiration=-1l;//警告的频率Intent intent =new Intent(this,AlertReceiver.class);//"com.lovo.an0714.location.alert"PendingIntent pi=PendingIntent.getBroadcast(this, 0, intent, 0);locationManager.addProximityAlert(latitude, longitude, radius, expiration, pi);Toast.makeText(this, "添加临近点成功", 3000).show();}}/** * 获取定位信息 *  * @param location */private String getLocationInfo(Location location2) {StringBuffer sb = new StringBuffer();if (location != null) {// 得到精度sb.append("经度:" + location.getLongitude());sb.append("纬度:" + location.getLatitude());sb.append("高度:" + location.getAltitude());sb.append("方向:" + location.getBearing());sb.append("速度:" + location.getSpeed());sb.append("精确度:" + location.getAccuracy());//showEditText.setText(sb.toString());} else {//sb.append("");// 没有获取则清空sb.append("没有获取位置信息");//showEditText.setText(sb.toString());}showProviderView.setText(sb);return sb.toString();}@Overridepublic void onLocationChanged(Location location) {this.location = location;Log.i("onLocationChanged", location+"");}@Overridepublic void onProviderDisabled(String provider) {}@Overridepublic void onProviderEnabled(String provider) {if(location == null){location = locationManager.getLastKnownLocation(provider);}}@Overridepublic void onStatusChanged(String provider, int status, Bundle extras) {}}

好多服务,看起来很方便呢,关键是要多去用,比如若定位自己手机,或亲友的~做什么圣光和暗牧的事就能多个保障了哈哈~

小平板重力感应坏了,我去啊,这才几天...泪奔..别说我躺着看横屏很方便了.但是这是bug啊bug懂么亲?该治!!



妈妈昨天在吐槽我的恋爱问题...额..

原创粉丝点击