Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android select video samsung stackoverflow

Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Video"),REQUEST_TAKE_GALLERY_VIDEO);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) {
                Uri selectedImageUri = data.getData();

                // OI FILE Manager
                filemanagerstring = selectedImageUri.getPath();

                // MEDIA GALLERY
                selectedImagePath = getPath(selectedImageUri);
                if (selectedImagePath != null) {

                    Intent intent = new Intent(HomeActivity.this,
                            VideoplayAvtivity.class);
                    intent.putExtra("path", selectedImagePath);
                    startActivity(intent);
                }
            }
        }
    }

    // UPDATED!
    public String getPath(Uri uri) {
        String[] projection = { MediaStore.Video.Media.DATA };
        Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
        if (cursor != null) {
            // HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL
            // THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA
            int column_index = cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        } else
            return null;
    }
Comment

PREVIOUS NEXT
Code Example
Java :: no java virtual machine found after searching the following locations 
Java :: javafx get actionevent id 
Java :: list of strings java 
Java :: how to get app categories android packagemanager 
Java :: maximum number from random number in java 
Java :: create a border java 
Java :: char value java 
Java :: how to print all package in java 
Java :: java add element to map 
Java :: convert stringbuffer to string in java 
Java :: resultset next method 
Java :: string java 
Java :: HashMap to store key and value pair. 
Java :: display 2d array 
Java :: java map remove all null values 
Java :: feign client url from properties 
Java :: get runtime java 
Java :: java load jar at runtime 
Java :: android studio check if email is valid java 
Java :: Java telegram bot dependency 
Java :: how to get ascii value of string letter in java 
Java :: java delete element from list 
Java :: java final variable 
Java :: how to start array index from 1 in java 
Java :: Java Creating a HashSet 
Java :: switch statement in java 
Java :: generic variable java 
Java :: declaring java variables 
Java :: java returns null 
Java :: java "-" 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =