當前位置: 首頁>>代碼示例>>Java>>正文


Java Environment.DIRECTORY_PICTURES屬性代碼示例

本文整理匯總了Java中android.os.Environment.DIRECTORY_PICTURES屬性的典型用法代碼示例。如果您正苦於以下問題:Java Environment.DIRECTORY_PICTURES屬性的具體用法?Java Environment.DIRECTORY_PICTURES怎麽用?Java Environment.DIRECTORY_PICTURES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.os.Environment的用法示例。


在下文中一共展示了Environment.DIRECTORY_PICTURES屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: saveAllSelectedStatus

private void saveAllSelectedStatus(ArrayList<String> statuses){
    String fileType = Environment.DIRECTORY_PICTURES;
    for(String status : statuses){
        if(status.endsWith(".jpg")){
            fileType = "Pictures";
        }else if(status.endsWith(".gif")){
            fileType ="Gifs";
        }else if(status.endsWith(".mp4")){
            fileType="Videos";
        }
        String [] splitStatus = status.split("/");
        String destinationFilename = android.os.Environment.getExternalStorageDirectory().getAbsolutePath()
                +"/WhatsAppSaver"+File.separatorChar+splitStatus[splitStatus.length-1];
        try {
            copyFile(new File(status),new File(destinationFilename));
            Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
            intent.setData(Uri.fromFile(new File(destinationFilename)));
            sendBroadcast(intent);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:Lekky71,項目名稱:WhatsAppStatusSaver,代碼行數:23,代碼來源:StatusSavingService.java

示例2: getOutputMediaFile

private File getOutputMediaFile(int type) {
    // Get environment directory type id from requested media type.
    String environmentDirectoryType;
    if (type == MEDIA_TYPE_IMAGE) {
        environmentDirectoryType = Environment.DIRECTORY_PICTURES;
    } else if (type == MEDIA_TYPE_VIDEO) {
        environmentDirectoryType = Environment.DIRECTORY_MOVIES;
    } else {
        Log.e(TAG, "Unsupported media type:" + type);
        return null;
    }

    return getOutputFile(
            type,
            Environment.getExternalStoragePublicDirectory(environmentDirectoryType)
    );
}
 
開發者ID:jonathan68,項目名稱:react-native-camera,代碼行數:17,代碼來源:RCTCameraModule.java

示例3: createImageFile

private File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = (isVideo ? "MPEG_" : "JPEG_") + timeStamp + "_";
    String dirType = isVideo ? Environment.DIRECTORY_MOVIES : Environment.DIRECTORY_PICTURES;
    File storageDir = isPublic ? getExternalStoragePublicDirectory(dirType) :
                                 getExternalFilesDir(dirType);
    if( !storageDir.exists() ) {
        storageDir.mkdirs();
    }
    File image = File.createTempFile(
            imageFileName,
            isVideo ? ".mp4" : ".jpg",
            storageDir
    );

    return image;
}
 
開發者ID:richardszabo,項目名稱:androidCameraTest,代碼行數:18,代碼來源:PhotoIntentTest.java

示例4: getOutputMediaFile

private File getOutputMediaFile(String fileName) {
    // Get environment directory type id from requested media type.
    String environmentDirectoryType;
    environmentDirectoryType = Environment.DIRECTORY_PICTURES;

    return getOutputFile(
            fileName + ".jpeg",
            Environment.getExternalStoragePublicDirectory(environmentDirectoryType)
    );
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:10,代碼來源:WebRTCModule.java

示例5: openFilePickerDialog

/**
 * Open a file picker dialog to ease select a new image from external storage.
 */
public void openFilePickerDialog() {
    DialogProperties properties = new DialogProperties();

    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    properties.selection_type = DialogConfigs.FILE_SELECT;
    // initial directory should be pictures directory
    properties.offset = new File("/mnt/sdcard" + File.separator + Environment.DIRECTORY_PICTURES);
    // show accepted image format only
    properties.extensions = new String[]{"jpg","jpeg","png","gif","bmp","webp"};

    FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties);
    dialog.setTitle(R.string.dialog_edit_doc_cover_image_select_title);
    dialog.setPositiveBtnName(getString(R.string.dialog_edit_doc_cover_image_select_ok));
    dialog.setNegativeBtnName(getString(android.R.string.cancel));

    dialog.setDialogSelectionListener(new DialogSelectionListener() {
        @Override
        public void onSelectedFilePaths(String[] files) {
            if (files.length > 0) {
                mImagePath = files[0];
                updateImage();
            }
        }
    });

    dialog.show();

    // There is a problem with library dialog theme, it does not support a light
    // primary color because header text color is always white.
    // With this hack (we had to study library layout) it ensures that header background
    // is ok.
    dialog.findViewById(R.id.header).setBackgroundColor(
            ContextCompat.getColor(getActivity(), R.color.colorAccent));
}
 
開發者ID:nfdz,項目名稱:foco,代碼行數:37,代碼來源:EditDocCoverDialog.java

示例6: getDirectoryPath

private String getDirectoryPath() {
    if (directoryPath == null || directoryPath.isEmpty()) {
        return Environment.DIRECTORY_PICTURES;
    } else {
        return directoryPath;
    }
}
 
開發者ID:Muddz,項目名稱:Viewshot,代碼行數:7,代碼來源:Viewshot.java

示例7: getImageDir

public static File getImageDir() throws NoExternalStorageException {
  return new File(getSignalStorageDir(), Environment.DIRECTORY_PICTURES);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:3,代碼來源:StorageUtil.java


注:本文中的android.os.Environment.DIRECTORY_PICTURES屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。