List of usage examples for android.content Intent EXTRA_ALLOW_MULTIPLE
String EXTRA_ALLOW_MULTIPLE
To view the source code for android.content Intent EXTRA_ALLOW_MULTIPLE.
Click Source Link
From source file:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java
private void browseForFiles() { Intent intent = new Intent().setType("*/*").putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) .setAction(Intent.ACTION_GET_CONTENT).addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent, getText(R.string.select_file)), CHOOSE_FILE_REQUEST_ID); }
From source file:org.fs.galleon.presenters.ToolsFragmentPresenter.java
private void dispatchSelectGalleryIntent() { if (view.isAvailable()) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(IMAGE_TYPE);// ww w.j a v a 2s . c om if (APICompats.isApiAvailable(Build.VERSION_CODES.JELLY_BEAN_MR2)) { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } view.startActivityForResult( Intent.createChooser(intent, view.getContext().getString(R.string.app_name)), REQUEST_PICK_GALLERY); } }
From source file:org.naturenet.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); userList = FetchData.getInstance().getUsers(); setContentView(R.layout.activity_main); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); toolbar = (Toolbar) findViewById(R.id.toolbar); navigationView = (NavigationView) findViewById(R.id.nav_view); logout = navigationView.getMenu().findItem(R.id.nav_logout); settings = navigationView.getMenu().findItem(R.id.nav_settings); header = navigationView.getHeaderView(0); sign_in = (Button) header.findViewById(R.id.nav_b_sign_in); join = (Button) header.findViewById(R.id.nav_b_join); nav_iv = (ImageView) header.findViewById(R.id.nav_iv); display_name = (TextView) header.findViewById(R.id.nav_tv_display_name); affiliation = (TextView) header.findViewById(R.id.nav_tv_affiliation); licenses = (TextView) navigationView.findViewById(R.id.licenses); setSupportActionBar(toolbar);//ww w .ja va2 s . c om ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); navigationView.setNavigationItemSelectedListener(this); add_observation_button = (ImageView) findViewById(R.id.addObsButton); selectionStack = new Stack<>(); selectedImages = new ArrayList<>(); mFirebase = FirebaseDatabase.getInstance().getReference(); tabLayout = (TabLayout) findViewById(R.id.TabLayout); if (getSupportActionBar() != null) getSupportActionBar().setDisplayShowTitleEnabled(false); //Handle the intent from Firebase Notifications. if (getIntent().getExtras() != null) { Bundle dataBundle = getIntent().getExtras(); //get the parent and context String parent = (String) dataBundle.get("parent"); String context = (String) dataBundle.get("context"); if (parent != null && context != null) { switch (context) { case "observations": Intent observationIntent = new Intent(MainActivity.this, ObservationActivity.class); observationIntent.putExtra("observation", parent); startActivity(observationIntent); break; case "ideas": { final Intent ideaIntent = new Intent(MainActivity.this, IdeaDetailsActivity.class); final ProgressDialog dialog; dialog = ProgressDialog.show(MainActivity.this, "Loading", "", true, false); dialog.show(); mFirebase.child(Idea.NODE_NAME).child(parent) .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { Idea idea = dataSnapshot.getValue(Idea.class); ideaIntent.putExtra("idea", idea); dialog.dismiss(); startActivity(ideaIntent); } @Override public void onCancelled(DatabaseError databaseError) { Toast.makeText(MainActivity.this, "Could not load Design Idea", Toast.LENGTH_SHORT).show(); } }); break; } case "activities": { final Intent projectIntent = new Intent(MainActivity.this, ProjectActivity.class); final ProgressDialog dialog; dialog = ProgressDialog.show(MainActivity.this, "Loading", "", true, false); dialog.show(); mFirebase.child(Project.NODE_NAME).child(parent) .addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { Project project = dataSnapshot.getValue(Project.class); projectIntent.putExtra("project", project); dialog.dismiss(); startActivity(projectIntent); } @Override public void onCancelled(DatabaseError databaseError) { Toast.makeText(MainActivity.this, "Could not load New Project", Toast.LENGTH_SHORT).show(); } }); break; } } } } //Set listener for the tab layout tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { //Position for the map view if (tab.getPosition() == 0) { getFragmentManager().popBackStack(); getFragmentManager().beginTransaction() .replace(R.id.fragment_container, ExploreFragment.newInstance(user_home_site)) .addToBackStack(ExploreFragment.FRAGMENT_TAG).commit(); } //Position for the gallery view else if (tab.getPosition() == 1) { getFragmentManager().popBackStack(); getFragmentManager().beginTransaction() .replace(R.id.fragment_container, new ObservationGalleryFragment()) .addToBackStack(ObservationGalleryFragment.FRAGMENT_TAG).commit(); } } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }); licenses.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(v.getContext()) .setView(View.inflate(MainActivity.this, R.layout.about, null)) .setNegativeButton("Dismiss", null).setCancelable(false).show(); } }); this.invalidateOptionsMenu(); /** * When user selects the camera icon, check to see if we have permission to view their images. */ add_observation_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_CODE_GALLERY); } else { setGallery(); } select.setVisibility(View.GONE); dialog_add_observation.setVisibility(View.VISIBLE); } }); sign_in.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (((NatureNetApplication) getApplication()).isConnected()) { MainActivity.this.goToLoginActivity(); } else { Toast.makeText(MainActivity.this, R.string.no_connection, Toast.LENGTH_SHORT).show(); } } }); join.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (((NatureNetApplication) getApplication()).isConnected()) { MainActivity.this.goToJoinActivity(); } else { Toast.makeText(MainActivity.this, R.string.no_connection, Toast.LENGTH_SHORT).show(); } } }); showNoUser(); getFragmentManager().beginTransaction().add(R.id.fragment_container, new LaunchFragment()).commit(); mUserAuthSubscription = ((NatureNetApplication) getApplication()).getCurrentUserObservable() .subscribe(new Consumer<Optional<Users>>() { @Override public void accept(Optional<Users> user) throws Exception { if (user.isPresent()) { onUserSignIn(user.get()); if (getFragmentManager().getBackStackEntryCount() == 0) { getFragmentManager().beginTransaction() .add(R.id.fragment_container, ExploreFragment.newInstance(user_home_site)) .commitAllowingStateLoss(); } tabLayout.setVisibility(View.VISIBLE); } else { if (signed_user != null) { onUserSignOut(); } showNoUser(); } } }); //click listener for when user selects profile image nav_iv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (signed_user != null) goToProfileSettingsActivity(); } }); display_name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (signed_user != null) goToProfileSettingsActivity(); } }); affiliation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (signed_user != null) goToProfileSettingsActivity(); } }); mLocationRequest = new LocationRequest(); mLocationRequest.setInterval(10000); mLocationRequest.setFastestInterval(5000); mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequest); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi .checkLocationSettings(mGoogleApiClient, builder.build()); result.setResultCallback(new ResultCallback<LocationSettingsResult>() { @Override public void onResult(@NonNull LocationSettingsResult locationSettingsResult) { final Status status = locationSettingsResult.getStatus(); if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) { try { status.startResolutionForResult(MainActivity.this, REQUEST_CODE_CHECK_LOCATION_SETTINGS); } catch (IntentSender.SendIntentException e) { Timber.w(e, "Unable to resolve location settings"); } } else if (status.getStatusCode() == LocationSettingsStatusCodes.SUCCESS) { requestLocationUpdates(); } } }); if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (lastLocation != null) { latValue = lastLocation.getLatitude(); longValue = lastLocation.getLongitude(); } } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_CODE_CHECK_LOCATION_SETTINGS); } latValue = 0.0; longValue = 0.0; dialog_add_observation = (LinearLayout) findViewById(R.id.ll_dialog_add_observation); add_observation_cancel = (ImageView) findViewById(R.id.dialog_add_observation_iv_cancel); camera = (Button) findViewById(R.id.dialog_add_observation_b_camera); gallery = (Button) findViewById(R.id.dialog_add_observation_b_gallery); select = (TextView) findViewById(R.id.dialog_add_observation_tv_select); gridview = (GridView) findViewById(R.id.dialog_add_observation_gv); gallery_item = (ImageView) findViewById(R.id.gallery_iv); cameraPhoto = new CameraPhoto(this); galleryPhoto = new GalleryPhoto(this); add_observation_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { selectedImages.clear(); select.setVisibility(View.GONE); dialog_add_observation.setVisibility(View.GONE); } }); /** * Click listener for when user selects images they want to upload. */ select.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Picasso.with(MainActivity.this).cancelTag(ImageGalleryAdapter.class.getSimpleName()); setGallery(); goToAddObservationActivity(false); } }); camera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isStoragePermitted()) { setGallery(); select.setVisibility(View.GONE); try { startActivityForResult(cameraPhoto.takePhotoIntent(), REQUEST_CODE_CAMERA); } catch (IOException e) { Toast.makeText(MainActivity.this, "Something Wrong while taking photo", Toast.LENGTH_SHORT) .show(); } } else Toast.makeText(MainActivity.this, R.string.permission_rejected, Toast.LENGTH_LONG).show(); } }); gallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isStoragePermitted()) { select.setVisibility(View.GONE); selectedImages.clear(); //Check to see if the user is on API 18 or above. if (usingApiEighteenAndAbove()) { Intent intent = new Intent(); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY_IMAGES); } else { //If not on 18 or above, go to the custom Gallery Activity Intent intent = new Intent(getApplicationContext(), ImagePicker.class); startActivityForResult(intent, IMAGE_PICKER_RESULTS); } } else Toast.makeText(MainActivity.this, R.string.permission_rejected, Toast.LENGTH_LONG).show(); } }); dialog_add_observation.setVisibility(View.GONE); }
From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java
private void addImage() { // when clicking attack the user should at first select an application to // choose the image with and then choose an image. // this intent is for getting the image Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT); getIntent.setType("image/*"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) getIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); // and this for getting the application to get the image with Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.setType("image/*"); // and this finally is for opening the chooserIntent for opening the // getIntent for returning the image uri. Yep, thanks android Intent chooserIntent = Intent.createChooser(getIntent, getResources().getString(R.string.select_image)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { pickIntent }); startActivityForResult(chooserIntent, ADD_PHOTO_CLICKED); // nope I don't want to be asked for a pwd when selected the image getActivity().getSharedPreferences(Constants.PREFERENCES, 0).edit().putBoolean(Constants.PWD_REQUEST, false) .apply();/* w w w . j ava 2s.co m*/ }
From source file:com.github.mjdev.libaums.usbfileman.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.create_file: new NewFileDialog().show(getFragmentManager(), "NEW_FILE"); return true; case R.id.create_dir: new NewDirDialog().show(getFragmentManager(), "NEW_DIR"); return true; case R.id.create_big_file: createBigFile();/* ww w .j ava2 s . c om*/ return true; case R.id.paste: move(); return true; case R.id.stop_http_server: if (serverService != null) { serverService.stopServer(); } return true; case R.id.run_tests: startActivity(new Intent(this, LibAumsTest.class)); return true; case R.id.open_storage_provider: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (device != null) { Log.d(TAG, "Closing device first"); device.close(); } Intent intent = new Intent(); intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); String[] extraMimeTypes = { "image/*", "video/*" }; intent.putExtra(Intent.EXTRA_MIME_TYPES, extraMimeTypes); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(intent, OPEN_STORAGE_PROVIDER_RESULT); } return true; case R.id.copy_from_storage_provider: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); startActivityForResult(intent, COPY_STORAGE_PROVIDER_RESULT); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:org.kontalk.ui.AbstractComposeFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private Intent createGalleryIntent(boolean useSAF) { Intent intent;/*from ww w .j av a 2 s.co m*/ if (!useSAF) { intent = SystemUtils.externalIntent(Intent.ACTION_GET_CONTENT) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { intent = SystemUtils.externalIntent(Intent.ACTION_OPEN_DOCUMENT); } return intent.addCategory(Intent.CATEGORY_OPENABLE).setType("image/*") .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }
From source file:org.kontalk.ui.ComposeMessageFragment.java
/** Starts an activity for picture attachment selection. */ @TargetApi(Build.VERSION_CODES.KITKAT)//from www . j a v a2s. co m private void selectGalleryAttachment() { Intent pictureIntent; if (!MediaStorage.isStorageAccessFrameworkAvailable()) { pictureIntent = new Intent(Intent.ACTION_GET_CONTENT).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { pictureIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } pictureIntent.addCategory(Intent.CATEGORY_OPENABLE).setType("image/*") .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(pictureIntent, SELECT_ATTACHMENT_OPENABLE); }
From source file:com.slarker.tech.hi0734.view.widget.webview.AdvancedWebView.java
@SuppressLint("NewApi") protected void openFileInput(final ValueCallback<Uri> fileUploadCallbackFirst, final ValueCallback<Uri[]> fileUploadCallbackSecond, final boolean allowMultiple) { if (mFileUploadCallbackFirst != null) { mFileUploadCallbackFirst.onReceiveValue(null); }/*from w w w.j a v a2 s . c o m*/ mFileUploadCallbackFirst = fileUploadCallbackFirst; if (mFileUploadCallbackSecond != null) { mFileUploadCallbackSecond.onReceiveValue(null); } mFileUploadCallbackSecond = fileUploadCallbackSecond; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); if (allowMultiple) { if (Build.VERSION.SDK_INT >= 18) { i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } } i.setType(mUploadableFileTypes); if (mFragment != null && mFragment.get() != null && Build.VERSION.SDK_INT >= 11) { mFragment.get().startActivityForResult(Intent.createChooser(i, getFileUploadPromptLabel()), mRequestCodeFilePicker); } else if (mActivity != null && mActivity.get() != null) { mActivity.get().startActivityForResult(Intent.createChooser(i, getFileUploadPromptLabel()), mRequestCodeFilePicker); } }
From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java
@Override public void addPhotoAlbum(LWQChooseImageSourceModule module) { Intent imagePicker = new Intent(Intent.ACTION_GET_CONTENT); imagePicker.setType("image/*"); imagePicker.addCategory(Intent.CATEGORY_OPENABLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { imagePicker.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }/*w ww . j a va 2 s . c o m*/ startActivityForResult(Intent.createChooser(imagePicker, "Choose photo(s)"), REQUEST_CODE_ALBUM); // Track viewing AnalyticsUtils.trackScreenView(AnalyticsUtils.SCREEN_CUSTOM_PHOTOS); }