title: Rate app on the press of back button
body: <p>I'm using this code to make the user rate our application. The problem is that I'm unable to find where to place this code so that when user exits the application by pressing the <strong>back</strong> button, a dialog will prompt the user to rate our app. Here is the code:</p>
  
  <pre><code>AlertDialog.Builder alert = new AlertDialog.Builder(FrontPage.this);
  alert.setTitle("Rate Us:");
  alert.setPositiveButton("Yes", new OnClickListener() {
  
      @Override
      public void onClick(DialogInterface dialog, int which) {
  
          Intent i = new Intent(Intent.ACTION_VIEW);
          i.setData(Uri.parse("market://details?id=" + getPackageName()));
          startActivity(i);
      }
  });
  
  alert.setNegativeButton("No", new OnClickListener() {
  
      @Override
      public void onClick(DialogInterface dialog, int which) {
          // TODO Auto-generated method stub
      }
  });
  alert.create();
  alert.show();
  </code></pre>