@Override public void handleMessage(Message msg) { if (msg.what == 0) { // 初始化数据 Bundle bundle = new Bundle(); boolean state = false; String data = msg.getData().getString("data"); GetUploadFileUrlReback result = new Gson().fromJson(data, GetUploadFileUrlReback.class); String message = result.getMes(); Log.e("myLog", "-----message" + message); if (result.getCode() == 0) { state = true; } bundle.putBoolean("state", state); bundle.putInt("type", 0); bundle.putString("msg", message); intent.putExtras(bundle); intent.setClass(AppSignActivity.this, AppSignResultActivity.class); startActivity(intent); finish(); } if (msg.what == 1) { Bundle bundle = new Bundle(); boolean state = false; String data = msg.getData().getString("data"); GetUploadFileUrlReback result = new Gson().fromJson(data, GetUploadFileUrlReback.class); String message = result.getMes(); Log.e("myLog", "-----message" + message); if (result.getCode() == 0) { state = true; } bundle.putBoolean("state", state); bundle.putInt("type", 1); bundle.putString("msg", message); intent.putExtras(bundle); intent.setClass(AppSignActivity.this, AppSignResultActivity.class); startActivity(intent); finish(); } if (msg.what == 2) { if (dialog == null) { return; } dialog.dismiss(); AMapLocation loc = (AMapLocation) msg.obj; Constant.location = loc; if (Constant.location.getErrorCode() == 0) { // 定位成功 wz.setText(Constant.location.getAddress()); } else { wz.setText("定位失败,请点击重试..."); Toast.makeText( AppSignActivity.this, "定位失败:" + Constant.location.getErrorInfo(), Toast.LENGTH_SHORT) .show(); } locationClient.stopLocation(); } }
/** 停止定位. 在Activity/Fragment的onPause方法中调用该方法 */ public static void stopLocation() { if (sAMapLocationClient != null) { sAMapLocationClient.stopLocation(); } }