public final class

ImagePicker

extends Object
java.lang.Object
   ↳ com.pspdfkit.document.image.ImagePicker

Class Overview

A helper class for launching gallery image picker or a camera for taking a picture.

Summary

Nested Classes
interface ImagePicker.OnImagePickedListener Interface for listening for image picker results. 
Public Constructors
ImagePicker(FragmentManager fragmentManager, String fragmentTag)
Creates an image picker object, start image picking or capturing by using startImageCapture() or startImageGallery()
Public Methods
static boolean deleteTemporaryFile(Context context, Uri imageUri)
Deletes temporary file previously created by capturing image through camera.
void setOnImagePickedListener(ImagePicker.OnImagePickedListener onImagePickedListener)
Sets on image picked listener.
void startImageCapture()

Starts camera application for capturing photos.

void startImageGallery()

Starts image gallery for picking images.

boolean wasStarted()
Returns true if an image picker request (for gallery or camera) was started and is running or false if none has been started.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ImagePicker (FragmentManager fragmentManager, String fragmentTag)

Creates an image picker object, start image picking or capturing by using startImageCapture() or startImageGallery()

Parameters
fragmentManager Fragment manager, supplied by the calling activity for fragment stack control.
fragmentTag Tag to be given to the fragment once added to the layout

Public Methods

public static boolean deleteTemporaryFile (Context context, Uri imageUri)

Deletes temporary file previously created by capturing image through camera.

Parameters
context The context to use.
imageUri Uri of file that should be removed.
Returns
  • true if file was removed, false otherwise.

public void setOnImagePickedListener (ImagePicker.OnImagePickedListener onImagePickedListener)

Sets on image picked listener. If set after some image picking events have already happened, the corresponding method will be called again. Calling this method will replace any previously set listener. You may provide null to clear the listener.

Parameters
onImagePickedListener ImagePicker.OnImagePickedListener that should be notified, or null to clear the listener.

public void startImageCapture ()

Starts camera application for capturing photos. Result can be observed by setting listener via setOnImagePickedListener(OnImagePickedListener).

This method adds this fragment instance to fragmentManager with tag fragmentTag.

public void startImageGallery ()

Starts image gallery for picking images. Result can be observed by setting listener via setOnImagePickedListener(OnImagePickedListener).

This method adds this fragment instance to fragmentManager with tag fragmentTag.

public boolean wasStarted ()

Returns true if an image picker request (for gallery or camera) was started and is running or false if none has been started. This method is useful to let the application determine if another request should be started or not (e.g. after a configuration change).

Returns
  • true if a request was already started by the application and is still running, or false if no request is running.