LogoLogo
v7.0.0
v7.0.0
  • TotalCross Overview
  • TotalCross Javadoc
  • TotalCross Changelog
  • Roadmap
  • Documentation
    • Getting Started
      • First embedded project with TotalCross
    • Components
      • Accordion
      • Aligned Labels
      • Button
      • Check
      • ComboBox
      • Dynamic Scroll
      • Edit
      • Floating Button
      • Gpiod
      • Grid
      • GridContainer
      • Image
      • ImageControl
      • ImageList
      • Label
      • Material Icons
      • Material Window
      • MessageBox
      • Multi Edit
      • Progress Bar
      • Progress Box
      • Radio
      • Radio Group
      • Scroll Container
      • Side Menu
      • Slider
      • Sliding Window
      • Spin List
      • Spinner
      • Switch
      • Tabbed Container
      • Velocimeter
    • APIs
      • API Overview
      • API Rest
      • Asynchronous Task
      • Camera
      • Control
        • Main Window
        • Window
        • Container
      • GPS
      • HTTPS and SSL
      • JSON
      • Maps
        • Maps - Deprecated
        • Static Map
      • Material Design Standards
      • Ninepath
      • Notifications
      • PrinterManager
      • Push Notification Firebase
      • Scanner
      • SOAP
      • Socket
      • SocketServer
      • SQLite Encryption
      • QR Code Generator
      • totalcross.sys
      • Youtube API
    • Creating an Issue
    • Contributing
      • Branch workflow
      • Writing documentation
    • Guides
      • App Architecture
        • Suggested Architecture
        • Why do Design Patterns help with the application's organization?
          • MVC Architecture Pattern
          • Template Pattern
          • Data Persistence: DAO Pattern.
        • Separation of concepts: What is the best way to create UI interfaces?
        • Positioning
          • Manual Positioning
        • Relative Positioning
        • Best practices to improve project maintenance
      • Device Simulator
      • Package your app from scratch
        • TotalCross SDK
        • Environment Variables in IDE
          • Eclipse
          • IntelliJ
        • Deploy your app with a dependecy TC
        • Deploy iOS
          • Using Development certificate to test your apps
      • Understanding TotalCross for Linux ARM
      • Running C++ applications with TotalCross
      • Web Services
    • Miscelaneous
      • Java JDK 8
      • Maven
      • Installing Visual Studio Code
    • FAQ
      • IMEI in Android 10
Powered by GitBook
On this page
  • Creation of a Notification
  • Content Needed to Create a Notification
  • A Simple Example
  • References

Was this helpful?

  1. Documentation
  2. APIs

Notifications

Notification is a message that will be displayed to the user outside of the application’s usual UI.

When you execute a command telling the system to issue a notification, it will appear as an icon in the notification area, and to see the details, the user opens the notification space.

The notification space is this area where the details are shown (also called the notification drawer) are areas controlled by the system and the user can see at any time.

Creation of a Notification

  • To specify actions and information that will be displayed to the user, use a Notification.Builder object.

  • To create a push notification, use Notification.Builder.build(), which is an example of the type of notification provided as previously defined specifications.

  • To notify a notification, simply pass the Notification object using NotificationManager.getInstance().Notify();

Content Needed to Create a Notification

The object on smartphones should contain the following:

  • A title, defined by title();

  • Detail text, defined by text();

A Simple Example

HelloTCNotification
import totalcross.notification.Notification;
import totalcross.notification.NotificationManager;
import totalcross.sys.Settings;
import totalcross.ui.Button;
import totalcross.ui.Edit;
import totalcross.ui.MainWindow;

public class HelloWorld extends MainWindow {
	private Button btnHello;

	public HelloWorld(){
		super("", NO_BORDER);
		Settings.uiAdjustmentsBasedOnFontHeight = true;
		setUIStyle(Settings.Material);
	}

	public void initUI() {
		Edit title = new Edit("Title");
		title.caption = "Title";
		add(title, LEFT+150, TOP+100, FILL-150, PREFERRED);
		
		Edit text = new Edit("Text");
		text.caption = "Text";
		add(text, LEFT+150, AFTER+50, FILL-150, PREFERRED);
		
		btnHello = new Button("Notify!");
		btnHello.addPressListener(
				(e) -> {
					Notification.Builder builder = new Notification.Builder();
					Notification notification = builder
							.title(title.getText())
							.text(text.getText())
							.build();
					NotificationManager.getInstance().notify(notification);
				});
		add(btnHello, CENTER, AFTER+150, PARENTSIZE+38, PARENTSIZE+8);
	  }
}

References

PreviousNinepathNextPrinterManager

Last updated 6 years ago

Was this helpful?

to see the complete example, go to our

You can also view this on how to create notifications.

GitHub
quick tutorial video