Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

拍照问题 #40

Closed
houjingwei opened this issue Mar 15, 2017 · 0 comments
Closed

拍照问题 #40

houjingwei opened this issue Mar 15, 2017 · 0 comments

Comments

@houjingwei
Copy link

private static File createMediaFile(Context context, String parentPath, int type) {
String state = Environment.getExternalStorageState();
File rootDir = state.equals(Environment.MEDIA_MOUNTED) ? Environment.getExternalStorageDirectory() : context.getCacheDir();

    File folderDir = new File(rootDir.getAbsolutePath() + parentPath);
    if (!folderDir.exists() && folderDir.mkdirs()) {

    }

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date());
    String fileName = APP_NAME + "_" + timeStamp + "";
    File tmpFile = null;
    switch (type) {
        case 1:
            tmpFile = new File(folderDir, fileName + POSTFIX);
            break;
        case 2:
            tmpFile = new File(folderDir, fileName + POST_VIDEO);
            break;
    }
    return tmpFile;
}

folderDir.mkdirs() false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants