Example usage for android.os StrictMode enableDeathOnFileUriExposure

List of usage examples for android.os StrictMode enableDeathOnFileUriExposure

Introduction

In this page you can find the example usage for android.os StrictMode enableDeathOnFileUriExposure.

Prototype

@UnsupportedAppUsage
public static void enableDeathOnFileUriExposure() 

Source Link

Document

Used by the framework to make file usage a fatal error.

Usage

From source file:com.android.settings.users.EditUserPhotoController.java

private void cropPhoto(Uri pictureUri) {
    // TODO: Use a public intent, when there is one.
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(pictureUri, "image/*");
    appendOutputExtra(intent, mCropPictureUri);
    appendCropExtras(intent);/*from ww  w.  ja  v  a  2s.  co m*/
    if (intent.resolveActivity(mContext.getPackageManager()) != null) {
        try {
            StrictMode.disableDeathOnFileUriExposure();
            mFragment.startActivityForResult(intent, REQUEST_CODE_CROP_PHOTO);
        } finally {
            StrictMode.enableDeathOnFileUriExposure();
        }
    } else {
        onPhotoCropped(pictureUri, false);
    }
}