public static boolean greenify(final Context context, final String pkg, final UserHandle user) {
		final long user_sn = Objects.requireNonNull((UserManager) context.getSystemService(USER_SERVICE)).getSerialNumberForUser(user);
		if (user_sn == - 1) return false;
		final Intent intent = new Intent(ACTION_GREENIFY).setPackage(GREENIFY_PKG).setData(Uri.parse("package:" + pkg + "#usn=" + user_sn));
		if (getGreenifyVersion(context) > 39500)        // EXTRA_CALLER_ID is supported in newer version of Greenify
			intent.putExtra(EXTRA_CALLER_ID, PendingIntent.getBroadcast(context, 0, new Intent(), FLAG_UPDATE_CURRENT))
					.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		final Activity activity = Activities.findActivityFrom(context);
		try {
			if (activity != null) activity.startActivityForResult(intent, 0);
			else context.startActivity(intent.putExtra("caller", PendingIntent.getBroadcast(context, 0, new Intent(), FLAG_UPDATE_CURRENT)));
		} catch (final ActivityNotFoundException e) {
			return false;
		}
		return true;
	}
Client helper for Greenify APIs

Created by Oasis on 2016/10/14.
mobile/src/main/java/com/oasisfeng/island/greenify/GreenifyClient.java