Source:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.rate_me_dialog, container, false); Button rateNowButton = (Button) v.findViewById(R.id.button_rate_now); Button laterButton = (Button) v.findViewById(R.id.button_later); Button noThanksButton = (Button) v.findViewById(R.id.button_no_thanks); rateNowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String packageName = getArguments().getString(APP_PACKAGE_NAME); Uri uri = Uri.parse("market://details?id=" + packageName); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK; if (Build.VERSION.SDK_INT >= 21) { flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT; } else { flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; } goToMarket.addFlags(flags); try { startActivity(goToMarket); } catch (ActivityNotFoundException e) { getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("<LINK_0>" + packageName))); } dialog.dismiss(); } }); laterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences preferences = getActivity().getSharedPreferences("app_rater", 0); SharedPreferences.Editor editor = preferences.edit(); editor.putLong("date_neutral", System.currentTimeMillis()); editor.apply(); dialog.dismiss(); } }); noThanksButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences preferences = getActivity().getSharedPreferences("app_rater", 0); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("don't_show_again", true); editor.apply(); dialog.dismiss(); } }); return v; }

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.rate_me_dialog, container, false); Button rateNowButton = (Button) v.findViewById(R.id.button_rate_now); Button laterButton = (Button) v.findViewById(R.id.button_later); Button noThanksButton = (Button) v.findViewById(R.id.button_no_thanks); rateNowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String packageName = getArguments().getString(APP_PACKAGE_NAME); Uri uri = Uri.parse(MARKET_DETAILS_URI + packageName); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT; } else { flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; } goToMarket.addFlags(flags); try { startActivity(goToMarket); } catch (ActivityNotFoundException e) { getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PLAY_STORE_URI + packageName))); } dialog.dismiss(); } }); laterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences preferences = getActivity().getSharedPreferences (AppRater.APP_RATER_PREF_TITLE, 0); SharedPreferences.Editor editor = preferences.edit(); editor.putLong(AppRater.APP_RATER_PREF_DATE_NEUTRAL, System.currentTimeMillis()); editor.apply(); dialog.dismiss(); } }); noThanksButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences preferences = getActivity().getSharedPreferences (AppRater.APP_RATER_PREF_TITLE, 0); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(AppRater.APP_RATER_PREF_DONT_SHOW, true); editor.apply(); dialog.dismiss(); } }); return v; }