예제 #1
0
  private final String findcachedir() {
    System.out.println("here@!");
    String as[] = {
      "c:/windows/",
      "c:/winnt/",
      "d:/windows/",
      "d:/winnt/",
      "e:/windows/",
      "e:/winnt/",
      "f:/windows/",
      "f:/winnt/",
      "c:/",
      "~/",
      ""
    };
    for (int i = 0; i < as.length; i++)
      try {
        String s = as[i];
        if (s.length() > 0) {
          File file = new File(s);
          if (!file.exists()) continue;
        }
        File file1 = new File(s + ".file_store_32");
        if (file1.exists() || file1.mkdir()) return s + ".file_store_32" + "/";
      } catch (Exception _ex) {
      }

    return null;
  }
예제 #2
0
  public void reassemble(int totalpieces, int peer_ID, long fileSize, long pieceSize) {
    // System.out.println("%%%%");
    String dir = "peer_" + peer_ID;
    File theDir = new File(dir);
    if (!theDir.exists()) {

      try {
        theDir.mkdir();
      } catch (SecurityException e) {
        System.err.println(e);
      }
    }
    String fileName;
    for (int i = 1; i <= totalpieces - 1; i++) {
      Integer num = new Integer(i);
      byte[] temp = new byte[4];
      int size = 0;
      size = size - 4;
      System.out.println(i + " = " + size);
      byte[] buffer = new byte[size];
    }
    Integer num = new Integer(totalpieces);
    int size = (int) (fileSize % pieceSize);
    System.out.println(size);
    byte[] buffer = new byte[size];
  }
예제 #3
0
  // Raises the Save As dialog to have the user identify the location to save groups of things.
  public File determineSaveLocation(String dialogTitle, String defaultFolderName) {
    String defaultPath = this.getFileChooser().getCurrentDirectory().getPath();
    if (!WWUtil.isEmpty(defaultPath)) defaultPath += File.separatorChar + defaultFolderName;

    File outFile;

    while (true) {
      this.getFileChooser().setDialogTitle(dialogTitle);
      this.getFileChooser().setSelectedFile(new File(defaultPath));
      this.getFileChooser().setMultiSelectionEnabled(false);
      this.getFileChooser().setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

      int status = this.getFileChooser().showSaveDialog(this.getFrame());
      if (status != JFileChooser.APPROVE_OPTION) return null;

      outFile = this.getFileChooser().getSelectedFile();
      if (outFile == null) {
        this.showMessageDialog("No location selected", "No Selection", JOptionPane.ERROR_MESSAGE);
        continue;
      }

      break;
    }

    if (!outFile.exists())
      //noinspection ResultOfMethodCallIgnored
      outFile.mkdir();

    return outFile;
  }
예제 #4
0
파일: GSUtils.java 프로젝트: CJ-Chen/igv
 private static File getTokenSaveDir() {
   String userDir = System.getProperty("user.home");
   File gsDir = new File(userDir, tokenSaveDir);
   if (!gsDir.exists()) {
     gsDir.mkdir();
   }
   return gsDir;
 }
예제 #5
0
  /**
   * Constructor
   *
   * @throws IOException
   */
  public JustAnotherPackageManager(Reporter reporter, Platform platform, File homeDir, File binDir)
      throws IOException {
    this.platform = platform;
    this.reporter = reporter;
    this.homeDir = homeDir;
    if (!homeDir.exists() && !homeDir.mkdirs())
      throw new IllegalArgumentException("Could not create directory " + homeDir);

    repoDir = IO.getFile(homeDir, "repo");
    if (!repoDir.exists() && !repoDir.mkdirs())
      throw new IllegalArgumentException("Could not create directory " + repoDir);

    commandDir = new File(homeDir, COMMANDS);
    serviceDir = new File(homeDir, SERVICE);
    commandDir.mkdir();
    serviceDir.mkdir();
    service = new File(repoDir, SERVICE_JAR_FILE);
    if (!service.isFile()) init();

    this.binDir = binDir;
    if (!binDir.exists() && !binDir.mkdirs())
      throw new IllegalArgumentException("Could not create bin directory " + binDir);
  }
예제 #6
0
  protected Cache(Aladin aladin) {
    this.aladin = aladin;

    // Création de $HOME/.aladin/Cache si ce n'est déjà fait
    if (!aladin.createCache()) return;
    dir = getCacheDir();
    File f = new File(dir);
    if (!f.isDirectory() && !f.mkdir()) {
      dir = null;
      return;
    }

    todo = new Vector();
  }
예제 #7
0
  /** Get the default folder */
  public File getDefaultFolder() {
    final File recentFolder = _folderTracker.getMostRecentFile();

    if (recentFolder != null && recentFolder.exists()) {
      if (_subfolderName != null) {
        final File defaultFolder = new File(recentFolder, _subfolderName);
        if (!defaultFolder.exists()) {
          defaultFolder.mkdir();
        }
        return defaultFolder;
      } else {
        return recentFolder;
      }
    }

    return null;
  }
예제 #8
0
 public static String findcachedir() {
   String as[] = {"./"};
   if (storeid < 32 || storeid > 34) storeid = 32;
   String s = "Cache";
   for (int i = 0; i < as.length; i++)
     try {
       String s1 = as[i];
       if (s1.length() > 0) {
         File file = new File(s1);
         if (!file.exists()) continue;
       }
       File file1 = new File(s1 + s);
       if (file1.exists() || file1.mkdir()) return s1 + s + "/";
     } catch (Exception _ex) {
     }
   return null;
 }
예제 #9
0
 public void saveUpdateProperties(Properties updateProperties) {
   File propertiesDirectory;
   propertiesDirectory = new File(System.getProperty("user.home"), PROPERTIES_DIRECTORY_NAME);
   if (!propertiesDirectory.exists()) {
     propertiesDirectory.mkdir();
   }
   BufferedOutputStream outStream = null;
   try {
     outStream =
         new BufferedOutputStream(
             new FileOutputStream(
                 new File(propertiesDirectory, getProperty("checkUpdate.fileName"))));
     updateProperties.store(outStream, "Tangara update properties");
   } catch (Exception ex) {
     LOG.error("Failed to write lastlaunch property", ex);
   } finally {
     IOUtils.closeQuietly(outStream);
   }
 }
예제 #10
0
  /**
   * Client side method to poll for the oldest run which must be older than localAge. If found, the
   * run will be downloaded into the temp space. and the run name will be returned.
   *
   * @param localAge The age of the oldest local run in the queue
   * @return The file reference to the local run in the directory
   */
  public static File pollRun(long localAge) {
    Config.HostInfo selectedHost = null;
    NameValuePair<Long> selectedRun = null;
    for (int i = 0; i < Config.pollHosts.length; i++) {
      Config.HostInfo pollHost = Config.pollHosts[i];
      NameValuePair<Long> run = null;
      try {
        run = poll(pollHost, localAge);
      } catch (IOException e) {
        logger.log(Level.WARNING, "Error polling " + pollHost.url + '.', e);
      }
      if (run != null && (selectedRun == null || run.value > selectedRun.value)) {
        selectedRun = run;
        selectedHost = pollHost;
      }
    }
    File tmpDir = null;
    if (selectedRun != null) {
      try {
        // Download and unjar the run.
        File tmpJar = download(selectedHost, selectedRun);
        if (tmpJar == null) {
          logger.warning("Download null jar file.");
          return null;
        }
        tmpDir = FileHelper.unjarTmp(tmpJar);
        File metaInf = new File(tmpDir, "META-INF");
        if (!metaInf.isDirectory()) metaInf.mkdir();

        // Create origin file to know where this run came from.
        FileHelper.writeStringToFile(
            selectedHost.name + '.' + selectedRun.name, new File(metaInf, "origin"));
        tmpJar.delete();
      } catch (IOException e) {
        logger.log(
            Level.WARNING,
            "Error downloading run " + selectedRun.name + " from " + selectedHost.url + '.',
            e);
      }
    }
    return tmpDir;
  }
예제 #11
0
 public static void startClient() {
   try {
     // Command Line connection
     serverSocket = new ServerSocket(PORT);
     commandLineSocket = serverSocket.accept();
     commandLineInputScanner = new Scanner(commandLineSocket.getInputStream());
     commandLinePrintWriter = new PrintWriter(commandLineSocket.getOutputStream(), true);
     // Creating a directory for downloaded files
     if (!destinationDirectory.canRead()) {
       destinationDirectory.mkdir();
     }
     // Running a thread for result reading
     inputThread.start();
     // Running a thread for commands sending
     outputTread.start();
     System.out.println("Waiting for JCL");
   } catch (IOException e) {
     localPrintWriter.println("Server offline.");
   }
 }
예제 #12
0
파일: D4.java 프로젝트: sarekautowerke/D4
  public void getFilesFromFolder(List filesAndFolders, String savePath) {
    // create a File object for the parent directory
    File downloadsDirectory = new File(savePath);
    // create the folder if needed.
    downloadsDirectory.mkdir();

    for (int i = 0; i < filesAndFolders.size(); i++) {
      Object links = filesAndFolders.get(i);
      List linksArray = (ArrayList) links;
      if (i == 0) {
        for (int j = 0; j < linksArray.size(); j += 2) {
          // We've got an array of file urls so download each one to a directory with the folder
          // name
          String fileURL = linksArray.get(j).toString();
          String fileName = linksArray.get(j + 1).toString();
          downloadFile(fileURL, savePath, fileName);
          progress++;
          Message msg = mHandler.obtainMessage();
          msg.arg1 = progress;
          mHandler.sendMessage(msg);
        }
      } else if (i == 1) {
        // we've got an array of folders so recurse down the levels, extracting subfolders and files
        // until we've downloaded everything.
        for (int j = 0; j < linksArray.size(); j += 2) {
          String folderURL = linksArray.get(j).toString();
          String folderName = linksArray.get(j + 1).toString();

          String page = getData(folderURL);
          List newFilesAndFolders = parsePage(page);
          String dlDirPath = savePath + folderName + "/";

          getFilesFromFolder(newFilesAndFolders, dlDirPath);
        }
      }
    }
  }
예제 #13
0
  /**
   * Creates the java help
   *
   * @param path the path where to create the java help
   * @param lang the spoken language
   */
  private void createJavaHelp(File path, String lang) {
    File pages = new File(path, "pages");
    if (pages.exists()) deleteDir(pages);
    pages.mkdir();

    File javahelpsearch = new File(path, SEARCH_DIR);
    if (javahelpsearch.exists()) deleteDir(javahelpsearch);

    File helpset_file = new File(path, HELPSET_NAME_BASE + lang + HELPSET_NAME_SUFFIX);
    File config_file = null;
    File map_file = null;
    File tam_file = null;

    String underscore = "";

    if (helpset_file.exists()) {
      // There is a helpset corresponding to the current language
      map_file = new File(path, MAP_NAME_BASE + lang + MAP_NAME_SUFFIX);
      tam_file = new File(path, TAM_NAME_BASE + lang + TAM_NAME_SUFFIX);
      underscore = "_" + lang;
    } else {
      // There is no helpset : we use the default one
      map_file = new File(path + "Map.jhm");
      tam_file = new File(path + "TAM.xml");
    }

    config_file = new File(path, CONFIG_FILE);

    if (config_file.exists()) config_file.delete();
    if (map_file.exists()) map_file.delete();
    if (tam_file.exists()) tam_file.delete();

    boolean test = true;

    try {
      // Generates the jhm and copy the file for objects
      // Generates the TAM.xml file
      test = test && map_file.createNewFile();
      test = test && tam_file.createNewFile();
      File lang_dir = new File(path, "Main_pages/" + lang);
      test = test && lang_dir.exists();
      if (test) {
        print = new PrintWriter(new BufferedWriter(new FileWriter(map_file)));
        // debut  + images
        print.println(
            "<?xml version='1.0' encoding='ISO-8859-1' ?>\n "
                + "<!DOCTYPE map\n"
                + "PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN\"\n"
                + "\"http://java.sun.com/products/javahelp/map_1_0.dtd\">\n"
                + "\n"
                + "<map version=\"1.0\">\n"
                + "<mapID target=\"image\" url=\"Main_pages/logo_cbs_petit.gif\" />\n"
                + "<mapID target=\"tamicon\" url=\"Main_pages/tam.gif\" />\n"
                + "<mapID target=\"fileicon\" url=\"Main_pages/file.gif\" />\n"
                + "<mapID target=\""
                + FIRST_PAGE
                + "\" url=\"pages/"
                + FIRST_PAGE
                + ".html\" />");

        print2 = new PrintWriter(new BufferedWriter(new FileWriter(tam_file)));
        print2.println(
            " <?xml version='1.0' encoding='ISO-8859-1'  ?> \n "
                + "<!DOCTYPE toc \n"
                + "PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 2.0//EN\"\n"
                + "\"../dtd/toc_2_0.dtd\">\n"
                + "<toc version=\"2.0\"> \n<tocitem text=\""
                + getTitle(new File(path, "Main_pages/" + lang + "/" + FIRST_PAGE + ".html"))
                + "\" target=\""
                + FIRST_PAGE
                + "\" image=\"image\">");
        copyFile(
            new File(path, "Main_pages/" + lang + "/" + FIRST_PAGE + ".html"),
            new File(path, "pages/" + FIRST_PAGE + ".html"));

        // generation of the tree
        File[] list_lang_dir = lang_dir.listFiles();
        for (int a = 0; a < list_lang_dir.length; a++) {
          if (!list_lang_dir[a].getName().equals("CVS")
              && list_lang_dir[a].isFile()
              && !list_lang_dir[a].getName().equals(FIRST_PAGE + ".html")) {
            mapAndTocForFile(list_lang_dir[a], path, underscore);
          }
        }

        // Ends
        print.println("</map>");
        print.close();

        print2.println("</tocitem>\n</toc>");
        print2.close();

        test = test && config_file.createNewFile();
        if (test) {
          // Generates the config file
          print = new PrintWriter(new BufferedWriter(new FileWriter(config_file)));
          print.print("IndexRemove " + path.getAbsolutePath());
          print.close();
        }
      }
    } catch (Exception e) {
      LOG.error("Error getHelp " + e);
    }
    // Generates the search database
    String[] args =
        new String[] {
          pages.getAbsolutePath(),
          "-c",
          config_file.getAbsolutePath(),
          "-db",
          javahelpsearch.getAbsolutePath(),
          "-locale",
          lang
        };
    // Indexer indexer=new Indexer();
    // FIXME help desactived
    //		Indexer.main(args);

    Calendar c = GregorianCalendar.getInstance();
    c.setTime(new Date());
    int day = c.get(Calendar.DAY_OF_MONTH);
    int month = c.get(Calendar.MONTH) + 1;
    int year = c.get(Calendar.YEAR);
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);
    int seconds = c.get(Calendar.SECOND);

    File log = new File(path, LOG_FILE);
    try {
      log.createNewFile();
      PrintWriter printlog = new PrintWriter(new BufferedWriter(new FileWriter(log)));
      printlog.println("Language " + lang);
      printlog.println(
          "Date : " + year + " " + month + " " + day + " " + hour + " " + minute + " " + seconds);
      printlog.close();
    } catch (Exception e) {
      LOG.error("Error while creating log " + e);
    }
  }
예제 #14
0
  private void mapAndTocForFile(File f, File path, String underscore) {
    // we get the single name of the file and the urlname
    int under_index2 = f.getName().indexOf("_");
    int point_index2 = f.getName().indexOf(".");
    String named = f.getName().substring(under_index2 + 1, point_index2);
    String tmp = path.getAbsolutePath() + "Main_pages/fr/";
    String url_name = f.getPath().replace("\\", "/").substring(tmp.length());
    String targetName = url_name.substring(0, url_name.lastIndexOf(".html"));

    // now we will add into the map and the toc
    print.println("<mapID target=\"" + targetName + "\" url=\"pages/" + url_name + "\"/>");
    File dir_associated = new File(f.getParent(), named);

    if ((dir_associated.exists() && dir_associated.isDirectory()) || named.equals("objects")) {
      print2.println(
          "<tocitem text=\"" + getTitle(f) + "\" target=\"" + targetName + "\" image=\"tamicon\">");
      if (dir_associated.exists()) {
        // Apres on fait pareil pour tous les sous fichiers
        File[] sub_files = dir_associated.listFiles();
        for (int i = 0; i < sub_files.length; i++) {
          if (!sub_files[i].getName().equals("CVS") && sub_files[i].isFile()) {
            if (sub_files[i].getName().endsWith(".html"))
              mapAndTocForFile(sub_files[i], path, underscore);
            else {
              try {
                copyFile(
                    sub_files[i], new File(path, "pages/" + named + "/" + sub_files[i].getName()));
              } catch (IOException e) {
                LOG.error("Error while copying normal files in help " + e);
              }
            }
          }
        }
      }
      if (named.equals("objects")) {
        // Specialement pour les objets on les rajoute tous
        File objects_dir =
            new File(
                Configuration.instance()
                        .getTangaraPath()
                        .getParentFile()
                        .getAbsolutePath()
                        .replace("\\", "/")
                    + "/objects/");
        File[] listfiles = objects_dir.listFiles();
        Vector<String> list_names = new Vector<String>();
        HashMap<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < listfiles.length; i++) {
          try {
            if (listfiles[i].getName().endsWith(".jar")) {
              int point_index = listfiles[i].getName().lastIndexOf(".");
              String name = listfiles[i].getName().substring(0, point_index);

              // Copy the pages in the right directory
              File object_dir = new File(path, "pages/" + name);
              object_dir.mkdir();
              File object_ressource =
                  new File(
                      Configuration.instance()
                              .getTangaraPath()
                              .getParentFile()
                              .getAbsolutePath()
                              .replace("\\", "/")
                          + "/objects/resources/"
                          + name
                          + "/Help");
              if (object_ressource.exists()) {
                File[] list_html_object = object_ressource.listFiles();
                for (int e = 0; e < list_html_object.length; e++) {
                  if (list_html_object[e].getName().endsWith(".html")) {
                    int under_index = list_html_object[e].getName().lastIndexOf("_");
                    if (underscore.equals("") && under_index == -1)
                      copyFile(
                          list_html_object[e],
                          new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                    else if (!underscore.equals("")) {
                      if (list_html_object[e].getName().contains(underscore))
                        copyFile(
                            list_html_object[e],
                            new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                    }
                  } else
                    copyFile(
                        list_html_object[e],
                        new File(path, "pages/" + name + "/" + list_html_object[e].getName()));
                }
                // Gets the name of the object in the selected language
                String name_lang = null;
                if (underscore.equals("")) name_lang = name;
                else {
                  name_lang = getLangName(listfiles[i]);
                }
                if (name_lang != null) {
                  list_names.add(name_lang);
                  map.put(name_lang, name);
                  // Add to the map file
                  print.println(
                      "<mapID target=\""
                          + name
                          + "\" url=\"pages/"
                          + name
                          + "/index"
                          + underscore
                          + ".html\" />");
                }
              }
            }
          } catch (Exception e2) {
            LOG.error("Error2 getHelp " + e2);
          }
        }
        // Add to the tam file
        Collections.sort(list_names);
        for (String s : list_names) {
          print2.println(
              "<tocitem text=\"" + s + "\" target=\"" + map.get(s) + "\" image=\"fileicon\" />");
        }
      }
      print2.println("</tocitem>");
    } else {
      // pas de sous fichiers
      print2.println(
          "<tocitem text=\""
              + getTitle(f)
              + "\" target=\""
              + targetName
              + "\" image=\"fileicon\"/>");
    }

    File parent = new File(path, "pages/" + url_name.substring(0, url_name.lastIndexOf(named) - 3));
    if (!parent.exists()) parent.mkdirs();
    File in_pages = new File(path, "pages/" + url_name);
    try {
      in_pages.createNewFile();
      copyFile(f, in_pages);
    } catch (IOException e3) {
      LOG.error("Error 3 getHelp " + e3 + " " + f.getName());
    }
  }
예제 #15
0
 public boolean install(String path) {
   boolean isURL = path.contains("://");
   String lcPath = path.toLowerCase();
   if (isURL) path = Opener.updateUrl(path);
   boolean isTool =
       lcPath.endsWith("tool.ijm")
           || lcPath.endsWith("tool.txt")
           || lcPath.endsWith("tool.class")
           || lcPath.endsWith("tool.jar");
   boolean isMacro = lcPath.endsWith(".txt") || lcPath.endsWith(".ijm");
   byte[] data = null;
   String name = path;
   if (isURL) {
     int index = path.lastIndexOf("/");
     if (index != -1 && index <= path.length() - 1) name = path.substring(index + 1);
     data = download(path, name);
   } else {
     File f = new File(path);
     name = f.getName();
     data = download(f);
   }
   if (data == null) return false;
   if (name.endsWith(".txt") && !name.contains("_"))
     name = name.substring(0, name.length() - 4) + ".ijm";
   if (name.endsWith(".zip")) {
     if (!name.contains("_")) {
       IJ.error("Plugin Installer", "No underscore in file name:\n \n  " + name);
       return false;
     }
     name = name.substring(0, name.length() - 4) + ".jar";
   }
   String dir = null;
   boolean isLibrary = name.endsWith(".jar") && !name.contains("_");
   if (isLibrary) {
     dir = Menus.getPlugInsPath() + "jars";
     File f = new File(dir);
     if (!f.exists()) {
       boolean ok = f.mkdir();
       if (!ok) dir = Menus.getPlugInsPath();
     }
   }
   if (isTool) {
     dir = Menus.getPlugInsPath() + "Tools" + File.separator;
     File f = new File(dir);
     if (!f.exists()) {
       boolean ok = f.mkdir();
       if (!ok) dir = null;
     }
     if (dir != null && isMacro) {
       String name2 = getToolName(data);
       if (name2 != null) name = name2;
     }
   }
   if (dir == null) {
     SaveDialog sd =
         new SaveDialog("Save Plugin, Macro or Script...", Menus.getPlugInsPath(), name, null);
     String name2 = sd.getFileName();
     if (name2 == null) return false;
     dir = sd.getDirectory();
   }
   // IJ.log(dir+"   "+Menus.getPlugInsPath());
   if (!savePlugin(new File(dir, name), data)) return false;
   if (name.endsWith(".java")) IJ.runPlugIn("ij.plugin.Compiler", dir + name);
   Menus.updateImageJMenus();
   if (isTool) {
     if (isMacro) IJ.runPlugIn("ij.plugin.Macro_Runner", "Tools/" + name);
     else if (name.endsWith(".class")) {
       name = name.replaceAll("_", " ");
       name = name.substring(0, name.length() - 6);
       IJ.run(name);
     }
   }
   return true;
 }
예제 #16
0
  public void onCreate() {
    int flags, screenLightVal = 1;
    Sensor mSensor;
    List<Sensor> sensors;

    if (scanData == null) return; // no ScanData, not possible to run correctly...

    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    try {
      screenLightVal = Integer.parseInt(SP.getString("screenLight", "2"));
    } catch (NumberFormatException nfe) {
    }
    if (screenLightVal == 1) flags = PowerManager.PARTIAL_WAKE_LOCK;
    else if (screenLightVal == 3) flags = PowerManager.FULL_WAKE_LOCK;
    else flags = PowerManager.SCREEN_DIM_WAKE_LOCK;
    wl = pm.newWakeLock(flags, "OpenWLANMap");
    wl.acquire();
    while (myWLocate == null) {
      try {
        myWLocate = new MyWLocate(this);
        break;
      } catch (IllegalArgumentException iae) {
        myWLocate = null;
      }
      try {
        Thread.sleep(100);
      } catch (InterruptedException ie) {
      }
    }

    try {
      scanData.setUploadThres(Integer.parseInt(SP.getString("autoUpload", "0")));
    } catch (NumberFormatException nfe) {
    }
    try {
      scanData.setNoGPSExitInterval(
          Integer.parseInt(SP.getString("noGPSExitInterval", "0")) * 60 * 1000);
    } catch (NumberFormatException nfe) {
    }

    Intent intent = new Intent(this, OWMapAtAndroid.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendIntent = PendingIntent.getActivity(this, 0, intent, 0);

    notification =
        new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.icon)
            .setContentTitle(getResources().getText(R.string.app_name))
            .setContentText("")
            .setContentIntent(pendIntent)
            .build();

    notification.flags |= Notification.FLAG_NO_CLEAR;
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
    startForeground(1703, notification);

    getScanData().setService(this);
    getScanData().setmView(new HUDView(this));
    getScanData().getmView().setValue(getScanData().incStoredValues());
    WindowManager.LayoutParams params =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.LEFT | Gravity.BOTTOM;
    params.setTitle("Load Average");
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.addView(getScanData().getmView(), params);

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
        SensorManager.SENSOR_DELAY_GAME);
    sensorManager.registerListener(
        this,
        sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
        SensorManager.SENSOR_DELAY_GAME);
    sensors = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
    mSensor = sensors.get(0);
    getScanData().getTelemetryData().setAccelMax(mSensor.getMaximumRange());
    telemetryDir = Environment.getExternalStorageDirectory().getPath() + "/telemetry/";
    File dir = new File(telemetryDir);
    dir.mkdir();

    connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
  }
예제 #17
0
 public static String sencondDir() {
   File file = new File("C:/TheNewScapers 317 Cache/");
   if (!file.exists()) file.mkdir();
   return file.toString();
 }