title: Let user crop image
body: <p>I am having a hard time in figuring out how to let the user crop the picture.
  I would like to give bitmap variable with loaded bitmap to crop the picture before setting it as wallpaper. But I'm failing to do so... Here is that i tried.</p>
  
  <p>First version. = Works as expected BUT the returned image is in poor resolution. Changing the output to higher value doesn't help. As I saw in some post it is not recommended to use camera as not all devices support this.</p>
  
  <pre><code>Intent intent = new Intent("com.android.camera.action.CROP");  
  String path = Images.Media.insertImage(context.getContentResolver(), loaded,null, null);
  Uri uri = Uri.parse(path);              
  intent.setData(uri);  
  intent.putExtra("crop", "true");  
  intent.putExtra("aspectX", 1);  
  intent.putExtra("aspectY", 1);  
  intent.putExtra("outputX", 300);  
  intent.putExtra("outputY", 300);  
  intent.putExtra("noFaceDetection", true);  
  intent.putExtra("return-data", true);                                  
  startActivityForResult(intent, 2);
  </code></pre>
  
  <p>Second. Load up image chooser, and crop afterwards. How can I configurate this to load crop directly on my image? Just like in version 1</p>
  
  <pre><code>Intent photoPickerIntent = new Intent(MediaStore.ACTION_PICK);
  photoPickerIntent.setData(uri);
  photoPickerIntent.putExtra("crop", "true");
  photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
  photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
  startActivityForResult(photoPickerIntent, 2);
  </code></pre>
  
  <p>And onActivity result</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (resultCode != RESULT_OK) { return; }
      if(requestCode == 2) {
          Bundle extras = data.getExtras();  
          if(extras != null ) {  
              Bitmap photo = extras.getParcelable("data");  
              loaded = photo;
          }
          WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
  
          try {
              myWallpaperManager.setBitmap(loaded);
          } catch (IOException e) {}
      }
  }
  </code></pre>
  
  <p>I do not know whever these are the correct methods to make this done, but I hope somebody could point me in the right direction. Which, why, and how to use. </p>
  
  <p><strong>Update:</strong> I am still waiting for someone to point out how to do it correctly, answers below are working but returning images in poor resolution, so they are not an option to use</p>