Example #1
0
 @Override
 public boolean onLocation(BDLocation location, LatLng latLng) {
   if (users != null) {
     GQZLog.debug(users.size() + "个");
     for (int i = 1; i < users.size(); i++) {
       BmobGeoPoint point = users.get(i).getGpsAdd();
       LatLng l = new LatLng(point.getLatitude(), point.getLongitude());
       GQZLog.debug(
           users.get(i).getNickname() + "latitude:" + l.latitude + ":/longitude" + l.longitude);
       MapUtil.drawBitmap(l, imgs.get(i));
     }
     MapUtil.drawBitmap(latLng, imgs.get(0));
   }
   return true;
 }
Example #2
0
  /**
   * 清理后台进程与服务
   *
   * @param cxt 应用上下文对象context
   * @return 被清理的数量
   */
  public static int gc(Context cxt) {
    long i = getDeviceUsableMemory(cxt);
    int count = 0; // 清理掉的进程数
    ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
    // 获取正在运行的service列表
    List<RunningServiceInfo> serviceList = am.getRunningServices(100);
    if (serviceList != null)
      for (RunningServiceInfo service : serviceList) {
        if (service.pid == android.os.Process.myPid()) continue;
        try {
          android.os.Process.killProcess(service.pid);
          count++;
        } catch (Exception e) {
          e.getStackTrace();
          continue;
        }
      }

    // 获取正在运行的进程列表
    List<RunningAppProcessInfo> processList = am.getRunningAppProcesses();
    if (processList != null)
      for (RunningAppProcessInfo process : processList) {
        // 一般数值大于RunningAppProcessInfo.IMPORTANCE_SERVICE的进程都长时间没用或者空进程了
        // 一般数值大于RunningAppProcessInfo.IMPORTANCE_VISIBLE的进程都是非可见进程,也就是在后台运行着
        if (process.importance > RunningAppProcessInfo.IMPORTANCE_VISIBLE) {
          // pkgList 得到该进程下运行的包名
          String[] pkgList = process.pkgList;
          for (String pkgName : pkgList) {
            GQZLog.debug("======正在杀死包名:" + pkgName);
            try {
              am.killBackgroundProcesses(pkgName);
              count++;
            } catch (Exception e) { // 防止意外发生
              e.getStackTrace();
              continue;
            }
          }
        }
      }
    GQZLog.debug("清理了" + (getDeviceUsableMemory(cxt) - i) + "M内存");
    return count;
  }