title: Android OnClickListner is not called on Button click
body: <p>An intent for an Activity (RluSvcMenu) is fired from a Service when a user clicks on the Notification item.  RluSvcMenu then successfully displays a custom dialog box with three option buttons (Copy/Next; Next; Quit).  All is well, except that when any of the three buttons is clicked, the Listener function does not seem to be called.  Here are the pertinent parts of the RluSvcMenu code:</p>
  
  <pre><code>package com.lovelady.android.RluApp;
  
  import android.app.Activity;
  import android.app.Dialog;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class RluSvcMenu extends Activity implements OnClickListener {
      private int action;
      private Button btnCopyNext;
  private Button btnNext;
      private Button btnQuit;
  private final int SVC_MENU_DIALOG = 1;
      private Dialog dialog;
      private final String MY_TAG = "RluSvcMenu";
      private final String MESSAGE1 = "onCreate message";
      private final String MESSAGE2 = "onPrepare message";
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
    showDialog(SVC_MENU_DIALOG);
    Log.d(MY_TAG, "showDialog() has completed.");
  }
  
  
      protected Dialog onCreateDialog(int id) {
          dialog = new Dialog(this);
  
          dialog.setContentView(R.layout.rlu_service_menu);
  
          dialog.setTitle("RLU_APP");
  
          TextView text = (TextView) dialog.findViewById(R.id.text);
          text.setText(MESSAGE1);
  
          ImageView image = (ImageView) dialog.findViewById(R.id.icon);
      image.setImageResource(R.drawable.ic_rlu);
  
      btnCopyNext = (Button) dialog.findViewById(R.id.BtnCopyNext);
      btnCopyNext.setOnClickListener(this);
  
          btnNext = (Button) dialog.findViewById(R.id.BtnNext);
      btnNext.setOnClickListener(this);
  
      btnQuit = (Button) dialog.findViewById(R.id.BtnQuit);
      btnQuit.setOnClickListener(this);
      return dialog;
  }
  
  public void onClick(View v) {
      action = v.getId() ;
      Toast.makeText(getApplicationContext()
              , "Button " + action + " clicked."
              , Toast.LENGTH_SHORT).show();
      Log.d(MY_TAG, "Button " + action + " clicked.");
      dialog.dismiss();
  }
  
  
  protected void onPrepareDialog(int id, Dialog dialog) {
  
      dialog.setContentView(R.layout.rlu_service_menu);
  
      TextView text = (TextView) dialog.findViewById(R.id.text);
      text.setText(MESSAGE2);
      ImageView image = (ImageView) dialog.findViewById(R.id.icon);
      image.setImageResource(R.drawable.ic_rlu_app);
  }
  }
  </code></pre>
  
  <p>The XML to build the "service menu" is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/layout_root"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="4dp"
            &gt;
  &lt;ImageView android:id="@+id/icon"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginRight="10dp"
             /&gt;
  &lt;TextView android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_toRightOf="@+id/icon"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dp"
            android:textColor="#FFF"
            /&gt;
  &lt;Button android:layout_height="wrap_content"
          android:layout_below="@+id/text"
          android:layout_toRightOf="@+id/icon"
          android:layout_width="wrap_content"
          android:id="@+id/BtnCopyNext"
          android:text="Copy/Next"&gt;&lt;/Button&gt;
  &lt;Button android:layout_height="wrap_content"
          android:layout_toRightOf="@+id/BtnCopyNext"
          android:layout_below="@+id/text"
          android:layout_width="wrap_content"
          android:id="@+id/BtnNext"
          android:text="Next"&gt;&lt;/Button&gt;
  &lt;Button android:layout_height="wrap_content"
          android:layout_toRightOf="@+id/BtnNext"
          android:layout_below="@+id/text"
          android:layout_width="wrap_content"
          android:id="@+id/BtnQuit"
          android:text="Quit"&gt;&lt;/Button&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>... and finally, the AndroidManifest.xml looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.lovelady.android.AppName"
        android:versionCode="1"
        android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="7" /&gt;
  
      &lt;application android:label="@string/app_name" 
                   android:icon="@drawable/ic_mainIcon"&gt;
          &lt;activity android:name=".RluSvcMenu"&gt;&lt;/activity&gt;
          &lt;activity android:name=".RluOverview"
                    android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
              &lt;!-- enable the search dialog to send searches to RluSearch --&gt;
              &lt;meta-data android:name="android.app.default_searchable"
                         android:value=".RluSearch" /&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".RluDetails"&gt;&lt;/activity&gt;
          &lt;activity android:name=".RluImportFile"&gt;&lt;/activity&gt;
          &lt;activity android:name=".RluImportFilteredFile"&gt;&lt;/activity&gt;
          &lt;activity android:name=".RluSearch"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.SEARCH" /&gt;
              &lt;/intent-filter&gt;
              &lt;meta-data android:name="android.app.searchable"
                         android:resource="@xml/searchable" /&gt;
          &lt;/activity&gt;
          &lt;service android:name=".RluManager"
                   android:exported="false"
                   android:label="@string/service_name"&gt;
          &lt;/service&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>What might cause touches to not be delivered to the Activity?  Are they going to the service instead?  If so, what can I do to get focus?  (I thought I'd get focus by putting up the dialog, but the only clue I have, from logcat, indicates:</p>
  
  <pre><code>07-09 21:04:20.060 I/InputDispatcher(  302): Delivering touch to current input \
                     target: action: 0, channel '409079b8 Rluapp (server)'
  </code></pre>
  
  <p>(where "Rluapp" is the value of @string/my_app, and the name of the package)</p>
  
  <p>... or what hole did I forget to fill in my Listener?  For all intents and purposes "nothing" happens when the buttons are pressed.</p>