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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:55:40+00:00 2026-05-21T18:55:40+00:00

I’ve tried and tried today just to get a custom message with 2 buttons

  • 0

I’ve tried and tried today just to get a custom message with 2 buttons and a TextView.
Ive got the XML alraight. But the code i tried to use just give me Force Close

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.main);
        contentView.setImageViewResource(R.id.Button01, R.drawable.icon);
        contentView.setTextViewText(R.id.Button01, "Hello, this message is in a custom expanded view");

Intent notificationIntent = new Intent(this, main.class);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

and im pretty lost so please dont send me to http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Ive tried.

Would be really happy if someone could show me from the beggining because i have litterly tried this all the day and would really really appreciate a good answer!

Thank you!

//Lukas

EDIT* FULL CODE TO VIKTOR

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RemoteViews;

public class main extends Activity {
    /** Called when the activity is first created. */
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);

        int icon = R.drawable.icon;
        CharSequence tickerText = "Hello";
        long when = System.currentTimeMillis();

        Notification notification = new Notification(icon, tickerText, when);

        notification.flags |= Notification.FLAG_ONGOING_EVENT;


        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

        RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.main);
        contentView.setImageViewResource(R.id.Button01, R.drawable.icon);
        contentView.setTextViewText(R.id.Button01, "Hello, this message is in a custom expanded view");


        notification.contentView = contentView;

        Intent notificationIntent = new Intent(this, main.class);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

        notification.contentIntent = contentIntent;
        final int CUSTOM_VIEW_ID = 1;
        mNotificationManager.notify(CUSTOM_VIEW_ID, notification);

    }
}

Stack trace:

04-27 14:43:07.035: ERROR/StatusBarService(337): couldn't inflate view for notification Com.haxxzor.multitask/0x1
04-27 14:43:07.035: ERROR/StatusBarService(337): android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.HorizontalScrollView
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.widget.RemoteViews.apply(RemoteViews.java:939)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at com.android.systemui.statusbar.StatusBarService.makeNotificationView(StatusBarService.java:524)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at com.android.systemui.statusbar.StatusBarService.addNotificationViews(StatusBarService.java:553)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at com.android.systemui.statusbar.StatusBarService.addNotification(StatusBarService.java:382)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at com.android.systemui.statusbar.CommandQueue$H.handleMessage(CommandQueue.java:178)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.os.Looper.loop(Looper.java:123)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at java.lang.reflect.Method.invoke(Method.java:507)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at dalvik.system.NativeStart.main(Native Method)
04-27 14:43:07.035: ERROR/StatusBarService(337): Caused by: android.view.InflateException: Binary XML file line #1: Class not allowed to be inflated android.widget.HorizontalScrollView
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.view.LayoutInflater.failNotAllowed(LayoutInflater.java:530)
04-27 14:43:07.035: ERROR/StatusBarService(337):     at android.view.LayoutInflater.createView(LayoutInflater.java:477)
04-27 14:43:07.035: ERROR/StatusBarService(337):     ... 17 more
04-27 14:43:10.113: ERROR/AndroidRuntime(815): FATAL EXCEPTION: main
04-27 14:43:10.113: ERROR/AndroidRuntime(815): android.app.RemoteServiceException: Bad notification posted from package Com.haxxzor.multitask: Couldn't expand RemoteViews for: StatusBarNotification(package=Com.haxxzor.multitask id=1 tag=null notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x2))
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1044)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at android.os.Looper.loop(Looper.java:123)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at java.lang.reflect.Method.invoke(Method.java:507)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-27 14:43:10.113: ERROR/AndroidRuntime(815):     at dalvik.system.NativeStart.main(Native Method)
04-27 14:47:12.065: ERROR/InputDispatcher(44): channel '40643090 com.notif/com.notif.main (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
04-27 14:47:12.065: ERROR/InputDispatcher(44): channel '40643090 com.notif/com.notif.main (server)' ~ Channel is unrecoverably broken and will be disposed!
04-27 14:47:31.551: ERROR/AndroidRuntime(885): FATAL EXCEPTION: main
04-27 14:47:31.551: ERROR/AndroidRuntime(885): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.notif/com.notif.main}: java.lang.IllegalMonitorStateException: object not locked by thread before notify()
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.os.Looper.loop(Looper.java:123)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at java.lang.reflect.Method.invoke(Method.java:507)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at dalvik.system.NativeStart.main(Native Method)
04-27 14:47:31.551: ERROR/AndroidRuntime(885): Caused by: java.lang.IllegalMonitorStateException: object not locked by thread before notify()
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at java.lang.Object.notify(Native Method)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at com.notif.main.onCreate(main.java:27)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-27 14:47:31.551: ERROR/AndroidRuntime(885):     ... 11 more
  • 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-21T18:55:41+00:00Added an answer on May 21, 2026 at 6:55 pm

    Since you have posted the error message, this line tells you why you’re not succeeding with the custom notification:

    Caused by: android.view.InflateException: Binary XML file line #1: Class not allowed to be inflated android.widget.HorizontalScrollView

    Remove the HorizontalScrollView and just test with simple TextViews / ImageViews.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.