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 3303770
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:59:31+00:00 2026-05-17T20:59:31+00:00

I would like to show a notification that displays the progress of an ongoing

  • 0

I would like to show a notification that displays the progress of an
ongoing operation. That works well for me.
But at the same time the remote view should contain cancel button to stop the ongoing operation. The usual content intent should still do something else, i.e. not cancel the ongoing operation. It seems though that I can only have one intent.

I have to specify a contentIntent that is launched when clicking on
the notification: If I don’t specify that I get something along those
lines:

E/ActivityManager(   62): Activity Manager Crash
E/ActivityManager(   62): java.lang.IllegalArgumentException: contentIntent required ...

For the “cancel” button I set another intent:

Intent cancelSyncIntent = new Intent("com.xyz.CANCEL_SYNC");
contentView.setOnClickPendingIntent(R.id.cancel_sync,
                                    PendingIntent.getBroadcast(context, 0,
                                    cancelSyncIntent, 0));

But this never works. I always get the content intent when the button
is clicked. It looks like I cannot use buttons in remote views of
notifications?!

I could probably display a text: “<< Press to cancel operation >>”, but that seems rather heavy handed.

Update: Afer J.’s recommendations:

    final Notification n = new Notification(R.drawable.gen_auto_notification_icon, context.getResources()
            .getString(
                    fastSyncOnly ? R.string.fast_synchronization_running_notification_title
                            : R.string.synchronization_running_notification_title), new Date().getTime());

    n.flags = Notification.FLAG_ONGOING_EVENT;

    final RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.in_progress_notification);
    n.contentView = contentView;

    // Intent cancelSyncIntent = new Intent("com.newsrob.CANCEL_SYNC");
    Intent cancelSyncIntent = new Intent();
    cancelSyncIntent.setClass(context, FireReceiver.class);
    PendingIntent pendingCancelSyncIntent = PendingIntent.getActivity(context, 0, cancelSyncIntent, 0);
    contentView.setOnClickPendingIntent(R.id.cancel_sync, pendingCancelSyncIntent);

    Intent showDashboardIntent = new Intent(context, DashboardListActivity.class);
    PendingIntent showDashboardPendingIntent = PendingIntent.getActivity(context, 0, showDashboardIntent, 0);
    n.contentIntent = showDashboardPendingIntent;
  • 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-17T20:59:31+00:00Added an answer on May 17, 2026 at 8:59 pm

    Short answer: You cannot have clickable child views in a notification view.

    Longer answer…

    I spent a day trying to get this to work as well and eventually gave up and looked at the Android source. It looks like everything happens in makeNotificationView() within StatusBarService.java. In there, the code inflates a layout named “status_bar_latest_event” for each row in the notification pull down shade. It grabs a ViewGroup from that view it just inflated named “content”, calls setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS) on it, and then adds your notification view as a child of that. So, assuming I understand how FOCUS_BLOCK_DESCENDANTS works, it appears there is no hope of your view or any of its children getting focus or click events.

    I also followed the logic of how the main PendingEvent that you associate with your Notification works. The same ViewGroup that hosts your Notification view gets a setOnClickListener() call on it to register a listener class named “Launcher”. When that class gets an onClick() event, it simply calls the send() method on the PendingIntent you associated with the Notification. I was hoping maybe the coordinate of the click might get passed along so I could at least attempt to compute which button was clicked on, but no such luck.

    Anyway, if anyone knows of a way to work around this, I’d love to hear it. For now, I’m just pulling my buttons out and moving on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display a progress bar while doing some work, but that would
I would like to show some hidden text in a Flex application and have
I would like to show some links only to authenticated users in an asp.net
I would like to show a set of consecutive numbers in a UIPickerView component
I would like to show an XML file in my .NET 2.0 WinForms app
I have a series of performance tests I would like to show as a
I'm using blogengine.net. I would like to show a default image in the H1
When using CDT I would like to have std::string show up in the 'variable'
Using Windows Forms, .NET 3.5 framework, language: c# I would like to show a
I would like to show the Shared Documents on a sub-site of a main

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.