Android Question Show icon in notification?

trueboss323

Active Member
Licensed User
Longtime 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.
 

trueboss323

Active Member
Licensed User
Longtime 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.
 
Upvote 0

barx

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

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

trueboss323

Active Member
Licensed User
Longtime 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
 
Upvote 0
Top