简体   繁体   中英

How to use this code to save the images inside my android camera app?

I built my own camera so it could be launched from inside my other android app, i want to save the images inside this app and not in the default gallery, i was using getExternalFilesDir() because i wanna keep the data just inside my app. But it is not working quite right, does anybody know what i have to change?? I do have the permission in my manifest. My phone is an HTC phone

private void dispatchTakePictureIntent(int actionCode) {

    imageURI = getExternalFilesDir(null) + File.separator
            + System.currentTimeMillis() + ".jpg";

    File mFile = new File(getFilesDir(), "newImage.jpg");
    if(!mFile.exists()) {
        try{
            mFile.createNewFile();
        } catch (Exception e){
            return;
        }
    }

    //Uri iURI = Uri.parse(imageURI);
    Log.v("camera", mFile.toString()); // Debugging statement
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mFile));
    startActivityForResult(takePictureIntent, actionCode);

}

Here is the code that i am using to do it.

要从图库中隐藏图像,您应该在包含图像的文件夹中创建.nomedia文件,或者创建自己的相机应用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM