コード例 #1
0
        public void onPictureTaken(byte[] data, Camera camera) {

          long time = System.currentTimeMillis();
          Date date = new Date(time);
          SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmssSSS");

          // ( (TextView)findViewById( R.id.save_file  )  ).setText("檔案寫入 : " +   sdf.format(date)
          // +".jpg 中..."    );

          // ( (TextView)findViewById( R.id.save_file  )  ).requestLayout();

          try {
            Thread.sleep(1000);
          } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }

          String path = "/sdcard/ez_Lua_Script_Camera/DCIM/" + sdf.format(date) + ".jpg";
          File file = new File(path);
          try {
            file.createNewFile();
            OutputStream os2 = new BufferedOutputStream(new FileOutputStream(file), 8192);
            os2.write(data);
            os2.close();

            ((TextView) findViewById(R.id.save_file))
                .setText("檔案寫入 : " + sdf.format(date) + ".jpg 完成");

            all_pics++;

            ((TextView) findViewById(R.id.shutter_times_screen))
                .setText("拍攝張數 : " + String.format("%05d", all_pics));

          } catch (IOException e) {
          }
          synchronized (semaphore) {
            semaphore.notify();
          }
        }
コード例 #2
0
  public void show_choose_Dialog() {
    File file = new File("/sdcard/ez_Lua_Script_Camera/lua_scripts/");
    File[] files = file.listFiles();
    list = new String[files.length];
    for (int i = 0; i < files.length; i++) list[i] = files[i].getName();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(res.getString(R.string.choose_lua));
    builder.setItems(
        list,
        new DialogInterface.OnClickListener() {

          public void onClick(DialogInterface dialog, int which) {
            lua_file = list[which];
            print_screen(
                res.getString(R.string.load)
                    + "\""
                    + list[which]
                    + "\""
                    + res.getString(R.string.file));
          }
        });
    builder.create().show();
  }