Android beginner's journey (3) information output

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.