GpsTraceService.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:MobileGuard 作者:
@Override
public void onLocationChanged(Location location) {
    // get location info
    double altitude = location.getAltitude();
    double longitude = location.getLongitude();
    double latitude = location.getLatitude();
    StringBuilder buffer = new StringBuilder();
    buffer.append("altitude:" + altitude + "\n");
    buffer.append("longitude:" + longitude + "\n");
    buffer.append("latitude:" + latitude + "\n");

    // get safe phone number
    String safePhone = ConfigUtils.getString(GpsTraceService.this, Constant.KEY_SAFE_PHONE, "");
    if(TextUtils.isEmpty(safePhone)) {
        Log.e(TAG, "safe phone is empty");
        return;
    }

    // send location info to safe phone number
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(safePhone, null, buffer.toString(), null, null);
    System.out.println("success send a sms to " + safePhone + ":\n" + buffer.toString());
    // stop service
    stopSelf();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号