Android Learning Day08

Source: Internet
Author: User

Static broadcast (to enable the program to receive broadcasts without booting)

The tag intent-filter is pretty much in a listening system called "Com.example.broadcasttest.MY_BROADCAST" action. If you receive it, let it go. Mybroadcastreceiver the onreceiver of this inheriting class to complete the next logical operation.

Dynamic processing:
First Intentfilter intentfilter = new Intentfiltet ();
Intentfilter. Addaction ("XXX Broadcast Code");

Then xxxreceiver variable name = new Xxxreceiver ();
Remember: Xxxreceiver this is to inherit broadcastreceiver this class
Then rewrite the onrcveiver (Context context,intent Intent) method
{
This is the thing that receives the code broadcast to carry on the content;
}
Last: Register the Listener
Registerreceiver (Networkchangereceiver,intentfilter);
(Note: the Registerreceiver () method is a method that belongs to the parent-class context)

On Destory () {
Unregisterreceiver (XX);
}
==============
A local broadcast cannot be received by a static registration method.
Remember: Dynamically registered broadcast receivers must be unregistered.
Question: Does mainactivity eventually inherit activity or context?

=====
The standard notation for opening a dialog box:
Alertdialog.builder Builder = new Alertdialog.builder (context);
Builder.settitle ("Warning");
Builder.setmessage ("Force offline, please login again");
Builder.setcancelable (FALSE);
Builder.setpositivebutton ("OK", new Dialoginterface.onclicklistener () {
@Override
public void OnClick (Dialoginterface dialog, int which) {

            }        });        builder.show();

=============
Activity Manager:

public class Activitycollector {
public static List

========
Problem:
Does mainactivity inherit the activity or inherit the context?

Android Learning Day08

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.