Android Question How to Display a Notification Icon, but not have it in the notification list

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hello

Can we display a notification icon only, and not have it shown in the pull down list. On My phone the service provider show's an icon but there is nothing in the list. How do we achieve this.

Regards

John.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
What do you see here?

I see that is it possible ? Is the this the code that allows it ?

B4X:
int layout =  R.layout.custom_notification ;
 RemoteViews contentView = new RemoteViews(ctx.getPackageName(), layout);
 contentView.setViewVisibility(R.id.custom_notification, View.INVISIBLE);
 mBuilder.setContent(contentView);

I was looking for help with the above code as I think this may do it. Maybe I'm wrong.

In my app I have the following code for creating the notification.

B4X:
Sub Process_Globals
   Dim n1 As Notification
End Sub
.
.
.
.
.
Private Sub CreateNotification(Title As String, Content As String, Icon As String, TargetActivity As Object, Sound As Boolean, Vibrate As Boolean) As Notification
   
   Dim p As Phone
   
   If p.SdkVersion >= 26 Then
       Dim nb As NotificationBuilder
       Dim Channel As NotificationChannelBuilder 'New object
       Dim ChannelID As String = "ies_atlas_hello"
       Dim ChannelName As String = "Atlas Hello"
       
       'Build a Channel
   
       If Channel.ChannelsSupported Then
           Channel.Initialize(ChannelID, ChannelName, Channel.IMPORTANCE_LOW)
           Channel.Build
       End If
       
       nb.Initialize(ChannelID)
       nb.OnGoingEvent = True
       nb.DefaultSound = Sound
       nb.DefaultVibrate = Vibrate
       nb.DefaultLight = False
       nb.ContentTitle = Title
       nb.ContentText = Content
       nb.setActivity(TargetActivity)
       nb.SmallIcon = Icon
       
       ' //set the return object for the notification object (n1) in this service
       n1 = nb.GetNotification
   Else
       n1.Initialize
       n1.Light = False
       n1.Vibrate = False
       n1.Sound = False
       n1.OnGoingEvent = True
       n1.Icon = Icon
       n1.SetInfo(Title, Content, TargetActivity)
   End If
   
   Return  n1
   
   
End Sub


Regards

John.
 
Upvote 0
Top