Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:01:03+00:00 2026-06-01T09:01:03+00:00

In my app, I open the camera and want to save that file with

  • 0

In my app, I open the camera and want to save that file with a specific name.
I use this code:

public void onLongPress(MotionEvent e) {
        // TODO Auto-generated method stub
        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File("new-photo-name.jpg")) );
        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

}
protected void onActivityResult1(int requestCode, int resultCode, Intent data) {
                    if (requestCode == CAMERA_PIC_REQUEST) {
                          Bitmap image = (Bitmap) data.getExtras().get("data");  
                    }   
}

It does open the camera, I can take and save the photo, but it does not give the good name.
Everytime when I save the picture, he gives the picture an other name, 1 name example is: “13333675392558.jpg”. I don’t understand how he comes with that kind of numbers.

Why does my code does not apply the name: “new-photo-name.jpg” ?

And/Or what do I wrong then?

Thanks already, Bigflow

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:01:05+00:00Added an answer on June 1, 2026 at 9:01 am

    I got it working, but don’t know the exact same problem yet, but this code worked for me:

    private Uri outputFileUri;
        public void onLongPress(MotionEvent e) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            File file = new File(Environment.getExternalStorageDirectory(), "/DCIM/Camera/new-photo-name.jpg");
    
            outputFileUri = Uri.fromFile(file);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, TAKE_PICTURE);
        }
    

    onLongPress has something to do with gesture (touch) actions, you could also use a button here.

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
          if (requestCode == TAKE_PICTURE){
                System.out.println("string of file name = "+outputFileUri.toString());
          }
    }
    

    Really small code, but works like a charm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an app that use the flashlight of the camera. I open the
I want to ask that , can I open iPhone camera in some limited
I want to write a app in which I open the camera take a
I have an app where I open the camera at onResume() method: @Override public
In my open source app, I want to let users insert a picture/video/sound/etc .
I have an open-source app which uploads photos to Facebook. To save bandwidth, the
Is it possible to open another app, like Camera, from a third-party app? I
My question is straight and simple. Open the camera app on any android device.
I'm using following code to open a gallery inside of my app Intent intent
I want to use camera preview in an activity. I want to add images(transparent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.