Notification problem

mrossen

Active Member
Licensed User
Longtime User
Hi,

If I use the following demo code I do not have the "Clear" button in the message view. Any one know know to get the "Clear" button so I can clear the view

B4X:
Dim n As Notification
   n.Initialize
   n.Icon = "icon"
   n.SetInfo("This is the title", "and this is the body.", "") 
   'Change Main (above) to "" if this code is in the main module.
   n.Notify(1)

Thanks,

Mogens
 

mrossen

Active Member
Licensed User
Longtime User
Hi,

On my phone (HTC One X) the message view is split up in two parts.
The upper part with has the headline "Running" and below that others with the headline "Messages". When I receive a SMS the notification it is under "Messages" and I can "Clear" them. With the demo code the notification is under "Running" and can not be cleared.

How do I get my notification down under "Messages" so the "Clear" button appears.

Is there a way to handle this?

Mogens
 
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Yes,
I also have tried to put n.AutoCancel = True after n.Notify(1)

B4X:
   Dim n As Notification
   n.Initialize
   n.Icon = "icon"
   n.AutoCancel = True
   n.SetInfo("This is the title", "and this is the body.", "") 
   'Change Main (above) to "" if this code is in the main module.
   n.Notify(1)

Mogens
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Is that ALL your code referring to the notification as it sounds like your notification is set as an OnGoingEvent

try adding

B4X:
n.OnGoingEvent = False
 
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Thanks for your help, but it is still not working :BangHead:

B4X:
Dim n As Notification
   n.Initialize
   n.Icon = "icon"
   n.AutoCancel = True
   n.OnGoingEvent = False
   n.SetInfo("This is the title", "and this is the body.", "") 
   'Change Main (above) to "" if this code is in the main module.
   n.Notify(1)

Mogens
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
hmmmm, that code works ok on my device running ICS. can you post a screenshot?
 
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi,

I have another notification running in a service in my app. Can this influence the problem?

Mogens
 
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi,

There is the screendumb,

"Løbende" = "Running" in danish

Mogens
 

Attachments

  • test.jpg
    test.jpg
    45.5 KB · Views: 184
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Do the 2 notifications have different ID Numbers?
 
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi,

I have the previous code in main activity, and this code in my service module with the purpose that the service not killed.

If I unmark " 'Notification1.Icon = "icon"" this notification is shown all the time and I do not want that.

Then I made the other notification for the purpose of showing messages.

B4X:
Sub Service_Create
    
   SMSInt.Initialize2("smsint", 999)
   
    Notification1.Initialize
    'Notification1.Icon = "icon" 'use the application icon file for the notification
   Notification1.AutoCancel = True
   Notification1.OnGoingEvent = False
    Notification1.Sound = False
   Notification1.Light = False
   Notification1.Vibrate = False
   
   'Make sure that the process is not killed
    Service.StartForeground(1, Notification1) 

End Sub

Mogens
 
Last edited:
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi,

Is there anyone there have seen a tutorial on this notification thing.

There is obviously something I do not understand.

Mogens
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
OK, the problem is that both your notifications have an ID of '1'.

Then in your service you use StartForeground which I believe creates a notification that cannot be removed.

leave the service as it is, change the activity to

B4X:
n.Notify(2)
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Got there in the end.
 
Upvote 0
Top