Regardless of the language, it is important to understand the output of information, such as VB's msgbox, JS's alert, and C #'s MessageBox. show. This is of great significance for debugging. Android outputs the following methods:
1. log output.It is divided into log. V, log. D, log. I, log. W, log. E, and log4net. It is distinguished by color and viewed in the logcat window.
Ii. Use alertdialog.In the displayed window, you can process the returned events.
Import Android. App. alertdialog;
Import Android. content. dialoginterface;
New alertdialog. Builder (login. This)
. Settitle ("this is a prompt! ")
. Setmessage ("this is the content of the prompt ")
. Setpositivebutton ("off", new dialoginterface. onclicklistener () {public void onclick (dialoginterface Di, int II ){}})
. Show ();
3. display in the Information bar.Use the toast. maketext command.
Toast. maketext (this, "test info", Toast. length_short). Show ();
4. display in the status bar.It involves clicking and entering another activity, so the workload is heavy.
Assume that a new acivity named newact already exists. For more information, see
Icationicationmanager Nm = (notificationmanager) getsystemservice (context. notification_service );
Notification n = new notification (R. drawable. Icon, "Hello, there! ", System. currenttimemillis ());
N. Flags = notification. flag_auto_cancel;
Intent I = new intent ();
I. setclass (add2.this, newact. Class );
Pendingintent Pi = pendingintent. getactivity (this, 0, I, 0 );
N. setlatesteventinfo (this, "button1", "Notification of button1", Pi );
Nm. Y (R. String. app_name, N );
For more information about notification settings, see