简体   繁体   中英

How to get Video name from recorded video in android?

I am developing a simple app for videos by using android camera. In my app I have a button having name "Make Video " and a list view which is for to show the video name recorded by my app. Now as I click the button it opens my mobile camera for recording but when I complete my recording the camera gives me two options. "Save" and "Discard". Now by clicking the "Save" option, I want to get the name of the recorded video and display it on my list view. Please help me I would be very thankful to you.

You can check my code below.

ImageView iv;
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        list =(ListView) findViewById(R.id.list);
        iv = (ImageView) findViewById(R.id.imageView1);
        Button makeVideo = (Button) findViewById(R.id.button1);
        makeVideo.setOnClickListener(new OnClickListener() 
        {

            @Override
            public void onClick(View v) 
            {
                //Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
                startActivityForResult(intent, 0);

            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);

//      Bitmap bm = (Bitmap) data.getExtras().get("data");
//      iv.setImageBitmap(bm);
    }

Pass the file path to the following method it will give the filename

public String getFileNameFromUrl(String path) {
        String[] pathArray = path.split("/");
        return pathArray[pathArray.length - 1];
    }

See below link to get file path

Getting the video path of capture video using default camera in android

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