/**
 * An Image Picker Plugin for Cordova/PhoneGap.
 */
package com.synconset;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;

public class ImagePicker extends CordovaPlugin {
	public static String TAG = "ImagePicker";
	 
	private CallbackContext callbackContext;
	private JSONObject params;
	 
	public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
		 this.callbackContext = callbackContext;
		 this.params = args.getJSONObject(0);
		if (action.equals("getPictures")) {
			Intent intent = new Intent(cordova.getActivity(), MultiImageChooserActivity.class);
			int max = 20;
			int desiredWidth = 0;
			int desiredHeight = 0;
			int quality = 100;
			if (this.params.has("maximumImagesCount")) {
				max = this.params.getInt("maximumImagesCount");
			}
			if (this.params.has("width")) {
				desiredWidth = this.params.getInt("width");
			}
			if (this.params.has("height")) {
				desiredHeight = this.params.getInt("height");
			}
			if (this.params.has("quality")) {
				quality = this.params.getInt("quality");
			}
			intent.putExtra("MAX_IMAGES", max);
			intent.putExtra("WIDTH", desiredWidth);
			intent.putExtra("HEIGHT", desiredHeight);
			intent.putExtra("QUALITY", quality);
			if (this.cordova != null) {
				this.cordova.startActivityForResult((CordovaPlugin) this, intent, 0);
			}
		}
		return true;
	}
	
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (resultCode == Activity.RESULT_OK && data != null) {
			ArrayList<String> fileNames = data.getStringArrayListExtra("MULTIPLEFILENAMES");
			JSONArray res = new JSONArray(fileNames);
			this.callbackContext.success(res);
		} else if (resultCode == Activity.RESULT_CANCELED && data != null) {
			String error = data.getStringExtra("ERRORMESSAGE");
			this.callbackContext.error(error);
		} else if (resultCode == Activity.RESULT_CANCELED) {
			JSONArray res = new JSONArray();
			this.callbackContext.success(res);
		} else {
			this.callbackContext.error("No images selected");
		}
	}
}

@@ -69,24 +69,68 @@
 synconset;%0A%0A
+import org.apache.cordova.PermissionHelper;%0A
 import org.a
@@ -784,43 +784,584 @@
 ;%0A%09%09
-if (action.equals(%22getPictures%22)) %7B
+protected final static String%5B%5D permissions = %7B Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE %7D;%0A%09%09if (action.equals(%22getPictures%22)) %7B%0A%09%09%09try %7B%0A%09%09%09       if(!PermissionHelper.hasPermission(this, permissions%5B0%5D)) %7B%0A%09%09%09%09 PermissionHelper.requestPermission(this, 1, Manifest.permission.READ_EXTERNAL_STORAGE);%0A%09%09%09   %7D%0A%09%09%09%7D%0A%09%09%09catch (IllegalArgumentException e)%0A%09%09%09%7B%0A%09%09%09%09callbackContext.error(%22Illegal Argument Exception%22);%0A%09%09%09%09PluginResult r = new PluginResult(PluginResult.Status.ERROR);%0A%09%09%09%09callbackContext.sendPluginResult(r);%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%09
 %0A%09%09%09

Update ImagePicker.java