title: AlertDialog return boolean value
body: <p>I am trying to include an AlertDialog builder within a method that prompts for a pin code and when the positive button is pressed, checks it against a database value and returns a true or false value to the method caller.</p>
  
  <p>For example: Adding/editing/deleting a user task requires a pin code. I don't want to generate a different AlertDialog for all three (and more) of these actions. I want to wrap the following code within a TaskService class that I can call from any activity, and react based on the result from within that activity.</p>
  
  <p>So TaskService.java would have:     </p>
  
  <pre><code>public boolean isCorrectPin(View v){
      AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
  
      final EditText editText = new EditText(context);
      builder.setView(editText);
  
      builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              if (editText.getText().toString()) == getPinCode(){
                  //return true
              }
          }
      });
  
      builder.show();
  }
  </code></pre>
  
  <p>and OpenTaskAdapter.java would have:</p>
  
  <pre><code>public void onBindViewHolder(ViewHolder holder, int position){
      holder.btnMarkAsComplete.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v){
              if (service.isCorrectPin(v) {
                  //complete task
              }
          }
      });
      holder.btnDelete.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v){
              if (service.isCorrectPin(v) {
                  //delete task
              }
          }
      });
  </code></pre>
  
  <p>It's important to note that these two button listeners could be in totally different activities.</p>