Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

select photo from camera android

private void pickFromGallery(){
       //Create an Intent with action as ACTION_PICK
       Intent intent=new Intent(Intent.ACTION_PICK);
       // Sets the type as image/*. This ensures only components of type image are selected
       intent.setType("image/*");
       //We pass an extra array with the accepted mime types. This will ensure only components with these MIME types as targeted.
       String[] mimeTypes = {"image/jpeg", "image/png"};
       intent.putExtra(Intent.EXTRA_MIME_TYPES,mimeTypes);
       // Launching the Intent 
       startActivityForResult(intent,GALLERY_REQUEST_CODE);
   }

    public void onActivityResult(int requestCode,int resultCode,Intent data){
          // Result code is RESULT_OK only if the user selects an Image
          if (resultCode == Activity.RESULT_OK)
          switch (requestCode){
              case GALLERY_REQUEST_CODE:
                  //data.getData returns the content URI for the selected Image
                  Uri selectedImage = data.getData();
                  imageView.setImageURI(selectedImage);
                  break;
          }
      }
Comment

PREVIOUS NEXT
Code Example
Java :: kmp java 
Java :: java summe array 
Java :: localdate java 
Java :: java map to list or array 
Java :: java random number between 2 values inclusive 
Java :: random numbers java 
Java :: difference between access specifiers and access modifiers in java 
Java :: java scanner string to int 
Java :: java loop 
Java :: Who is James Gosling 
Java :: java list distinct by object attribute 
Java :: how to get input form combobox java 
Java :: string to byte array java utf-8 
Java :: arraylist items into string 
Java :: tableau de classe java 
Java :: implementing iterator for linked list java 
Java :: reverse a integer in java 
Java :: How to perform quick sort, in Java? 
Java :: how to assert that an exception is thrown java 
Java :: how to check the current user in firebase android 
Java :: Add delay to code in Android 
Java :: tic tac toe in java 
Java :: unique elements in array java 
Java :: java enums 
Java :: android kill other app programmatically by package 
Java :: java hash password 
Java :: Java How to use Set? 
Java :: java scan a file 
Java :: java string to integer 
Java :: java long to hours minutes and seconds 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =