个人冲刺(六)——体温上报app(一阶段)
阅读原文时间:2023年07月09日阅读:2

任务:完成了自动获取定位信息以及自动获取时间功能

自动获取定位信息

public void onReceiveLocation(BDLocation location){
//此处的BDLocation为定位结果信息类,通过它的各种get方法可获取定位相关的全部结果
//以下只列举部分获取地址相关的结果信息
//更多结果信息获取说明,请参照类参考中BDLocation类中的说明
String addr = location.getAddrStr(); //获取详细地址信息
String country = location.getCountry(); //获取国家
String province = location.getProvince(); //获取省份
String city = location.getCity(); //获取城市
String district = location.getDistrict(); //获取区县
String street = location.getStreet(); //获取街道信息
String adcode = location.getAdCode(); //获取adcode
String town = location.getTown();
//获取乡镇信息
text4=(EditText)findViewById(R.id.tv_text4);
text4.setText(country+province+city+district+town+street+adcode);
}

自动获取时间

public void autoTimeAndDate(View view)
{
text2=(EditText)findViewById(R.id.tv_text2);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss
//获取当前时间
Date date = new Date(System.currentTimeMillis());
text2.setText(simpleDateFormat.format(date));
}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章