Skip to content

Advanced usage

Bohdan Semeniuk edited this page Oct 3, 2016 · 3 revisions

Please make sure you are familiar with Documentation before you proceed.

PickRequest customization

QiPick.in(activityLauncher) returns a PickRequest object which can be used to customize requested pick results:

  • allowOnlyLocalContent(boolean) pass true to restrict content that is not available locally on device and should be downloaded. Works on Honeycomb or later (API 11+)
  • withCameraPicsDirectory(String or File) - sets a directory to which pictures taken by camera will be saved. Useful only when camera is a pick source
  • withRequestType(int) - sets a request type integer. Helpful when app has different types of pick requests that should be distinguished when getting result
  • withAllowedMimeType(String) - sets MIME type of files that can be picked. It is the only way for pre-KitKat
  • withAllowedMimeTypes(Set<String> or List<String> or String...) - sets multiple exact MIME types of files that can be picked. Only works for KitKat and later (API 19+). If you use withAllowedMimeType(String) then only types within the argument passed will be available for pick. Probably better to not use both methods at the same time

All calls can be chained.

PickRequest trigger result

Also PickRequest returns an int value of trigger result. This value defines whether firing the PickRequest was successful. If not, the value is an error code and the request is not fired. Error codes are defined in PickTriggerResult

UriUtils

This class has a bunch of useful static methods for working with Uri objects. They are mainly designed to work with image Uris returned by the library but should work with others as well.

  • contentExists(Context, Uri) returns true if content specified by Uri exists
  • deleteContent(Context, Uri) deletes content defined by Uri. Use with caution
  • saveContentToFile(Context, Uri, File) saves content defined by Uri to the File supplied
  • getMimeType(Context, Uri) returns a String MIME type of Uri content if it can be determined
  • getFileExtension(Context, Uri) returns a String file extension of Uri content if it can be determined

QiPick camera result handling methods

  • getLastCameraUri(Context) returns Uri of a file to which last successfully triggered PickRequest that had camera pick source would request to write camera result.
  • deleteLastCameraPic(Context) deletes content defined by return of the method above
Clone this wiki locally