Custom notification with two action button

I am using following code to generate notifications with two action button and some details. Please help me, why i am not able to see action button in notification?

public static void sendNotification(Context mContext, int mode, String title, String message) { try { RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.custom_notification);

// Set Notification Title String strtitle = "Instevent"; // Set Notification Text String strtext = "Event has created"; // Open NotificationView Class on Notification Click Intent intent = new Intent(mContext, MainActivity.class); // Send data to NotificationView Class intent.putExtra("title", strtitle); intent.putExtra("text", strtext); // Open Activity PendingIntent pIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext) // Set Icon .setSmallIcon(R.drawable.ic_address_book) // Set Ticker Message .setTicker("Ticker message") // Dismiss Notification .setAutoCancel(true) // Set PendingIntent into Notification .setContentIntent(pIntent) // Set RemoteViews into Notification .setContent(remoteViews); // Locate and set the Image into customnotificationtext.xml // ImageViews remoteViews.setImageViewResource(, R.drawable.ic_action_accept); remoteViews.setTextViewText(, "Custom notification"); remoteViews.setTextViewText(, "This is a custom layout"); remoteViews.setTextViewText(, "This is a custom layout"); // Create Notification Manager NotificationManager notificationmanager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); // Build Notification with Notification Manager notificationmanager.notify(0,; } catch (Exception e) { e.printStackTrace(); Log.print("Notification====>>", e.getMessage()); }



<RelativeLayout xmlns:android="" xmlns:app="" android:layout_width="match_parent" android:layout_height="match_parent" > <RelativeLayout android:id="@+id/rlMainNotification" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/bg_rounded_white" android:padding="10dp" > <ImageView android:id="@+id/nfImage" android:layout_width="50dp" android:layout_height="50dp" android:scaleType="fitXY" android:src="@drawable/ic_group" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginStart="5dp" android:layout_toEndOf="@+id/nfImage" android:layout_toRightOf="@+id/nfImage" android:orientation="vertical" > <TextView android:id="@+id/nfEventName" style="@style/BlackTextN" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="5dp" android:paddingRight="5dp" android:singleLine="true" android:text="The Big Meeting" android:textSize="16sp" /> <TextView android:id="@+id/nfEventTime" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:paddingLeft="7dp" android:paddingRight="5dp" android:singleLine="true" android:text="4:15 - 5:15 PM" android:textColor="#8b8b8b" android:textStyle="normal" /> <TextView android:id="@+id/nfEventAddress" style="@style/GrayColorN" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:paddingLeft="7dp" android:paddingRight="5dp" android:singleLine="true" android:text="The Big Conference Room" android:textColor="#8b8b8b" android:textStyle="normal" /> <View android:layout_width="fill_parent" android:layout_height="1dp" android:layout_marginLeft="6dp" android:layout_marginStart="6dp" android:layout_marginTop="5dp" android:background="#dcdcdc" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2" > <TextView android:id="@+id/nfDecline" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:drawableLeft="@drawable/ic_action_cancel" android:drawablePadding="10dp" android:drawableStart="@drawable/ic_action_cancel" android:gravity="center_vertical" android:text="@string/decline" android:textColor="#676767" /> <TextView android:id="@+id/nfAccept" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:drawableLeft="@drawable/ic_action_accept" android:drawablePadding="10dp" android:drawableStart="@drawable/ic_action_accept" android:gravity="center_vertical" android:text="@string/accept" android:textColor="#676767" /> </LinearLayout> </LinearLayout> </RelativeLayout> </RelativeLayout>

-------------Problems Reply------------

I had a similar error in my App. The problem was that RemoteViews does not support every kind of layout or view.

In your case, I think the problem is the <View/> part in your custom_notification.xml. Try removing or replacing it with a supported layout element. You can find them here:

Category:android Views:1 Time:2018-02-05

Related post

  • google custom search with two radio buttons 2012-04-06

    Here is my code i am using for custom search, <div id="cse-search-form" style="width: 100%;">Loading</div> <script src="" type="text/javascript"></script> <script type="text/javascript"> goo

  • Python CGI Script: Basic HTML Form With Two Submit Buttons 2011-07-25

    I have a basic html form which I want to use with two submit buttons. The CGI script takes the form value and processes it (regardless of which submit button used), but I want each button to be associated with different actions later in the script, i

  • Multi-line EditText with Done action button 2010-06-06

    Is it possible to have an EditText widget with android:inputType="textMultiLine" set, and android:imeOptions="actionDone" at the same time? I'd like a multi-line edit box, with the action button on the keyboard to be Done, not Enter (Carriage Return)

  • Post custom text with facebook like button 2012-01-22

    i am having some tweets like things and i would like to post that custom text with facebook like button. is it possible if yes then how. thanks --------------Solutions------------- You should add OpenGraph meta tags to the page located on URL you lin

  • Is it possible to create a custom notification with controls such as buttons in Android? How? 2011-06-01

    According to the Android Developers' Guide, it is possible to create a custom notification view. However, is it possible to create one with controls such as buttons and text views? If yes, how? Note that I think it has something to do with PendingInt

  • jQuery Cycle: Custom Pagination with Previous & Next Buttons 2011-08-24

    I have a slideshow that requires custom markup for the pagination, which also includes previous & next buttons. I'm using jQuery Cycle, but I'm having trouble working with both a custom pager and previous & next buttons. This is what I want t

  • Wordpress Custom loop with two types of posts with different amounts 2010-09-19

    I have a category names "notes", I need on every page of the loop to show up to 10 notes, and up to 4 regular posts. They both should be ordered by date. i.e. I posted 1 note, note A, 1 hour ago and another note, note b, 5 hours ago, I also posted to

  • Alignment issues with two-line button 2011-08-02

    I'm trying to figure out why a two-line button in my application is being shifted a couple of pixels lower than the other buttons: This does not happen if I shorten the text on the third button until it fits on one line, which tells me it has somethi

  • How to handle routing with two actions with the same number of paramaters in MVC3? 2011-09-21

    Possible Duplicate: ActionLink to show parameters in URL instead of querystring? I have the following routes: routes.MapRoute( "List", // Route name "{Home}/{list}/{id}/{name}", // URL with parameters new { controller = "Home", action = "List", id =

  • UIAction with two delete buttons 2011-04-12

    I have an ActionSheets with 2 delete buttons, "delete all" and "delete selected item". Since delete is an destructive behavior, should i definitely keep them as "destructive buttons" or can i keep them as normal buttons without any destructive button

  • Custom listview with two buttons in each row 2011-07-12

    I have spent literally two days trying to sort this issue. If anyone could help I would be massively appreciative. What I'm trying to achieve: Have a ListView, whereby the player can add new entries (players), through a text field (for the player nam

  • mvc custom routes with multiple submit buttons 2009-07-28

    So I have a custom route as such: routes.MapRoute( "Wizard", // Route name "Wizard/{page}", // URL with parameters new { controller = "Wizard", action = "Index" } // Parameter defaults ); and have the following on my View: <% Html.BeginForm("Conti

  • Custom UITableViewCell with UIButton: which button has been clicked? 2012-03-06

    I'm developing an iOS 4 application with latest SDK and XCode 4.2. I have a UITableView with sections and with custom UITableViewCell. Every cell has a UIButton and all of these buttons has the same target for UIControlEventTouchUpInside. This is my

  • Submitting a jQuery ajax form with two submit buttons 2009-09-01

    I have a form that looks like this: <form action="/vote/" method="post" class="vote_form"> <input type="hidden" name="question_id" value="10" /> <input type="image" src="vote_down.png" class="vote_down" name="submit" value="down" />

  • Custom dialog with listview and button always fullscreen 2011-01-14

    I want to create a custom dialog that contains a listview and buttons below the listview. The buttons should be below the listview but always visible (layout_alignParentBottom="true"). I have created an xml that works quite well, but only on long lis

  • Validate Form using Jquery with two submit button 2011-04-26

    I have a single form and there are 2 submit buttons on that with 3 text boxes. On button A text box 1 should validate and n submit button B the other 2 should validate. I have used submit handler and submitting the form using ajax. My problem is if I

  • IOS: IBAction with two actions 2011-10-18

    In my app I have an ibaction and inside it I have 2 different instruction with an "if" if (i == 0) //do instruction set 1 if (i == 1) //do instruction set 2 // and everytime I push button i change from 0 to 1 or from 1 to 0 the problem is that if I r

  • UItableView custom cell with a plus button on the left side (outside table view) 2011-11-17

    I want to add a plus button outside my table view cell (on the left side), but the button should get scrolled if I am scrolling the table. Does anyone has a solution for this??? Also, there are 8 different sections in my table. There is no need to sh

  • How to deal with two submit buttons in a form? 2011-11-28

    I don't understand this, if I do this and I click the check out button, the page won't go to the check out page, <form action="cart.php" method="post" id="form-cart"> <button name="update" id="update" type="submit" value="Update cart">Upd

  • Custom validator with master page button click 2012-02-02

    i have a custom validator in a content page <asp:CustomValidator id="CustomValidator1" runat="server" OnServerValidate="RevisionValidate" ControlToValidate="TextBoxRevisionOrder" ErrorMessage="Invalid RevOrder Format"> </asp:CustomValidator

  • selected item on custom listview with contextual action bar 2012-02-13

    I recently started using android actionbars and contextual action bars (CAB). I have just one activity which is a ListActivity. Basically I use the following code snipped to "activate" the CAB: ListView listView = getListView(); listView.setChoiceMod

  • How can I create a List of a custom class with two fields and get output? 2011-02-23

    I need to make list of a gene sequence in Java and the starting positions of the parts that I care. I use a .txt file as input then search "GT" in the sequence. Once I find it, I want to store it in an array with the corresponding index. I couldn't m

  • if statement with two actions on a single line 2010-06-17

    Im trying to reset $i to 0 and print the word this doable the way im trying to pull it off? class="customGal'.($i == '2' ? $i = '0' && 'margin' : NULL).'" Thanks in advance. --------------Solutions------------- Why do it in such a

  • Sort Array Using Custom Selector With Two Arguments 2010-12-19

    I'm trying to sort an array of NSStrings but i'm unsure how to actually pass parameters into the @selector method. Here is why I'm trying to do //After the optional: id like to pass a UITextField.text but not sure how. NSArray *sortedSection = [wordS

Copyright (C), All Rights Reserved.

processed in 0.220 (s). 11 q(s)