Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6124985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:11:45+00:00 2026-05-23T16:11:45+00:00

An intent for an Activity (RluSvcMenu) is fired from a Service when a user

  • 0

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:

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);
}
}

The XML to build the “service menu” is:

<?xml version="1.0" encoding="utf-8"?>
<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"
          >
<ImageView android:id="@+id/icon"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginRight="10dp"
           />
<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"
          />
<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"></Button>
<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"></Button>
<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"></Button>
</RelativeLayout>

… and finally, the AndroidManifest.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.lovelady.android.AppName"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:label="@string/app_name" 
                 android:icon="@drawable/ic_mainIcon">
        <activity android:name=".RluSvcMenu"></activity>
        <activity android:name=".RluOverview"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <!-- enable the search dialog to send searches to RluSearch -->
            <meta-data android:name="android.app.default_searchable"
                       android:value=".RluSearch" />
        </activity>
        <activity android:name=".RluDetails"></activity>
        <activity android:name=".RluImportFile"></activity>
        <activity android:name=".RluImportFilteredFile"></activity>
        <activity android:name=".RluSearch">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                       android:resource="@xml/searchable" />
        </activity>
        <service android:name=".RluManager"
                 android:exported="false"
                 android:label="@string/service_name">
        </service>
    </application>
</manifest>

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:

07-09 21:04:20.060 I/InputDispatcher(  302): Delivering touch to current input \
                   target: action: 0, channel '409079b8 Rluapp (server)'

(where “Rluapp” is the value of @string/my_app, and the name of the package)

… or what hole did I forget to fill in my Listener? For all intents and purposes “nothing” happens when the buttons are pressed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:11:46+00:00Added an answer on May 23, 2026 at 4:11 pm

    Hmmm, I suspect the dialog is running in a different thread? Well anyway if you use one and alert dialog they have DialogInterface.onClickListener class that handles that, there may be a better way to overcome the problem, but changing the code to and actual custom dialog fixes this.

    Here is your original code modified with that fix, this is probably better anyway since you can then put the dialog in it’s own file/class etc.

    public class BtnNoWorky extends Activity {
        private int action;
        private Button btnCopyNext;
        private Button btnNext;
        private Button btnQuit;
        private final int SVC_MENU_DIALOG = 1;
        private final String MY_LABEL = "BtnNoWorky";
        private final String MESSAGE1 = "Msg from onCreateDialog";
        private final String MESSAGE2 = "Msg from onPrepare";
        private myDialog D = null; 
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            Log.d(MY_LABEL, "onCreate()");
            super.onCreate(savedInstanceState);
    
            Log.d(MY_LABEL, "Show dialog") ;
            //showDialog(SVC_MENU_DIALOG);
            D = new myDialog(this);
            D.show();
    
            Log.d(MY_LABEL, "showDialog() has completed.");
        }
    
        public class myDialog extends Dialog implements OnClickListener {
    
        public myDialog(Context context) {
                super(context,0);
        }
    
        public myDialog(Context context, int theme) {
                super(context, theme);
        }
    
        protected myDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
                super(context, cancelable, cancelListener);
                // TODO Auto-generated constructor stub
            }
    
        public void onCreate(Bundle saved) {
            //Log.d(MY_LABEL, "onCreateDialog - Creating dialog");
    
            //Log.d(MY_LABEL, "onCreateDialog - setContentView");
            setContentView(R.layout.bnw_dialog);
    
            //Log.d(MY_LABEL, "onCreateDialog - setTitle");
           setTitle("BtnNoWorky");
    
            //Log.d(MY_LABEL, "onCreateDialog - setText");
            TextView text = (TextView) findViewById(R.id.text);
            text.setText(MESSAGE1);
    
            //Log.d(MY_LABEL, "onCreateDialog - setImageResource");
            ImageView image = (ImageView) findViewById(R.id.icon);
            image.setImageResource(R.drawable.icon);
    
            //Log.d(MY_LABEL, "onCreateDialog - Instantiate btnCopyNext");
            btnCopyNext = (Button)findViewById(R.id.BtnCopyNext);
            btnCopyNext.setOnClickListener(this);
    
            //Log.d(MY_LABEL, "onCreateDialog - Instantiate btnNext");
            btnNext = (Button) findViewById(R.id.BtnNext);
            btnNext.setOnClickListener(this);
    
            //Log.d(MY_LABEL, "onCreateDialog - Instantiate btnQuit");
            btnQuit = (Button)findViewById(R.id.BtnQuit);
            btnQuit.setOnClickListener(this);
    
            //Log.d(MY_LABEL, "onCreateDialog - Returning...");
    
    
        }
    
        @Override
        public void onClick(View v) {
            action = v.getId() ;
            Toast.makeText(getApplicationContext()
                    , "Button " + action + " clicked."
                    , Toast.LENGTH_SHORT).show();
            Log.d(MY_LABEL, "Button " + action + " clicked.");
            dismiss();
        }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main activity, then i call a new activity intent from this.
I launch an activity to capture a picture from camera: Intent i = new
When I use startActivity(Intent) to load an activity with the theme set to Theme.Dialog
I have my remote service which tries to run an activity from a different
I have an Activity that starts a Service. In my Activity: startService(new Intent(this, MyService.class));
how can i transfer data from BroadcastReceiver to activity? I tried it with intent
I launch an activity from my widget using an Intent with some extra, anyway
Somehow my callback doesn't work... from a sending activity: Intent intent=new Intent(); intent.setAction(Constructor.rob.call); sendBroadcast(intent);
I am using below code from one of my activity to start another Intent
I've got Activity A which fires up the Camera intent via: Intent intent =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.