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