/** * Sets up and returns the default share intent for allowing the user to share the selected movie * * @return the share intent */ private Intent getDefaultShareIntent() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); int currentapiVersion = android.os.Build.VERSION.SDK_INT; // FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET was deprecated as of API 21 // This intent flag is important so that the activity is cleared from recent tasks // whenever the activity is finished/closed if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } else { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); } Movie selectedMovie = getIntent().getParcelableExtra(DetailActivity.EXTRASCURRENTMOVIE); if (selectedMovie != null) { intent.putExtra( Intent.EXTRA_SUBJECT, getString(R.string.detail_share_subject).concat(" ").concat(selectedMovie.getTitle())); // Build text for share provider String sharedText = selectedMovie .getTitle() .concat(" - ") .concat(selectedMovie.getDescription()) .concat(" ") .concat(getString(R.string.detail_share_hashtag)); intent.putExtra(Intent.EXTRA_TEXT, sharedText); } return intent; }