This line of code
startActivity(Intent.createChooser(shareIntent, "Share images to.."));
That means you create an intent object which is used to start a dialog activity for user to choose which activity to handle your shareIntent. So, in this case the intent to show chooser dialog activity need the flag FLAG_ACTIVITY_NEW_TASK
You can try:
Intent chooserIntent = Intent.createChooser(shareIntent, "Share images to..");
chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(chooserIntent);