How do I edit the text of foreground service notifications?

  • Thread starter Thread starter Darkmisc
  • Start date Start date
  • Tags Tags
    Edit Text
AI Thread Summary
A user sought assistance in creating a timer that remains active on the lock screen after pressing the power button, considering the use of a foreground notification. They initially encountered issues with modifying the notification's title and text, which remained static despite code changes. The problem was resolved when they realized that not setting an icon with .setSmallIcon was the cause of the issue, leading to successful updates of the notification's text and title.
Darkmisc
Messages
222
Reaction score
31
TL;DR Summary
I'd like to run a timer in a foreground notification. I thought I could use the setContextText command for this, but it doesn't change the text in the notification at all.
Hi everyone

I'd like to make a timer that continues to run on the lock screen after the power button is pressed. I thought I could use a foreground notification for this and used code from this page:

In particular, I thought I could modify the following lines of code:

[CODE lang="java" title="notification"] Notification.Builder notification = new Notification.Builder(this, CHANNELID)
.setContentText("Activity Recognition is running....")
.setContentTitle("Obesity Point");[/CODE]

However, it seems setContentText and setContentTitle do nothing. No matter what I put in the quotation marks, my notification title is " Timer is running" and the text is "Tap for more information or to stop the app".

How do I change the text and title?

Thanks
 
Technology news on Phys.org
Nevermind. The problem was that I didn't set an icon with .setSmallIcon. The text changes now that I've done that.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top