Android Question Show icon in notification?

trueboss323

Active Member
Licensed User
Hello,
Is there a way I can show only the app icon in the notification tray? I don't want to show a notification, but just the app icon itself. Thanks.
 

Erel

Administrator
Staff member
Licensed User
Notifications always have a body. If I remember correctly the notification will use some default text if you set all the fields to be empty.
 

trueboss323

Active Member
Licensed User
I tried setting all the fields to empty, and it showed up empty when I tested it. But how is it possible to set just the app icon, because i've seen other applications setting an icon without showing a notification.
 

Erel

Administrator
Staff member
Licensed User
I'm not familiar with any way to hide the notification item.
 

trueboss323

Active Member
Licensed User
Is it possible maybe there is a custom Notification library for it? I do not seem to be able to find one.
 

barx

Well-Known Member
Licensed User
I've never seen a way to do it...

Show us some Java code example and maybe we can implement it.
 

trueboss323

Active Member
Licensed User
Well I don't know any Java, but here is some code that I found
B4X:
//Check the SystemTray is supported
        if (!SystemTray.isSupported()) {
            System.out.println("SystemTray is not supported");
            return;
        }
        final PopupMenu popup = new PopupMenu();
        final TrayIcon trayIcon =
                new TrayIcon(createImage("images/bulb.gif", "tray icon"));
        final SystemTray tray = SystemTray.getSystemTray();
     
        // Create a pop-up menu components
        MenuItem aboutItem = new MenuItem("About");
        CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
        CheckboxMenuItem cb2 = new CheckboxMenuItem("Set tooltip");
        Menu displayMenu = new Menu("Display");
        MenuItem errorItem = new MenuItem("Error");
        MenuItem warningItem = new MenuItem("Warning");
        MenuItem infoItem = new MenuItem("Info");
        MenuItem noneItem = new MenuItem("None");
        MenuItem exitItem = new MenuItem("Exit");
     
        //Add components to pop-up menu
        popup.add(aboutItem);
        popup.addSeparator();
        popup.add(cb1);
        popup.add(cb2);
        popup.addSeparator();
        popup.add(displayMenu);
        displayMenu.add(errorItem);
        displayMenu.add(warningItem);
        displayMenu.add(infoItem);
        displayMenu.add(noneItem);
        popup.add(exitItem);
     
        trayIcon.setPopupMenu(popup);
     
        try {
            tray.add(trayIcon);
        } catch (AWTException e) {
            System.out.println("TrayIcon could not be added.");
        }
In VB you would normally use
B4X:
NotifyIcon1.Visible = True
 

Erel

Administrator
Staff member
Licensed User
As I wrote in my previous answer I'm not familiar with any way to create such a notification.
 
Top