Mainactivity as follows:Package Cc.testnetworkchange;import Android.os.bundle;import android.app.activity;/** * Demo Description: * Change of network connection using broadcast monitoring device * It is also possible to monitor if the device has been disconnected from the network */public class Mainactivity extends Activity {@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.main
For more information, see: http://developer.android.com/training/monitoring-device-state/connectivity-monitoring.htmlGenerally, some scheduled tasks are set during development, such as repeated alarm clocks and scheduled tasks started in the background. However, if our network is not connected, there is no need to start the tasks that need to connect to the network.We can use connectivitymanager to check whether the network is connected or not.By chan
: listens to which URI the content provider's notification, the database URI//notifyfordescendents: If true, so long as the content://sms begins with the data change of the URI, you can receive notifications, such as content:/ /sms/inbox. Actually write dead true can//third parameter: Represents the instance of the content observer (inherited Contentobserver implementation class here) Cr.registercontentobserver (Uri.parse ("content://s MS "), True, new Myobserver (New Handler ())); } class M
public class Networkstatereceiver extends Broadcastreceiver {@Override public void onreceive (context context, Inten T intent) {SYSTEM.OUT.PRINTLN ("network status Changed"); The detection API is not less than 23 because the getnetworkinfo (int networktype) method is deprecated if API23 (Android.os.Build.VERSION.SDK_INT Registering the listener in the Ingress classAndroid Network Monitoring
Implementation of mutual monitoring between two service
In actual development, you may need to use two service to monitor each other, this example is to implement this function for reference.
Service A:
public class ServiceA extends Service {private static final String TAG = ServiceA.class.getSimpleName ();
Mybinder Mbinder;
Myserviceconnection mserviceconnection;
Pendingintent mpendingintent;
@Override public void OnCreate () {supe
Scrolltouchlisener mtouchlisener;
Gesture monitoring private gesturedetector mdetector;
/** * When creating objects using the New keyword, call the/public Scrollviewgroup (context) {This (context, NULL);
/** * Call/Public scrollviewgroup when used in XML file (context, AttributeSet attrs) {This (context, attrs, 0); /** * is invoked in an XML file, and the custom attribute is used when calling/public Scrollviewgroup (context, AttributeSet attrs, i
public static Interface Viewtreeobserver.onpredrawlistenerLet's look at the definitions in the API:class overview:The interface defined for the callback function to be executed when the view tree is about to be drawn.Common methods:Public abstract Boolean Onpredraw ()The callback function to execute when the view tree is about to be drawn. At this point all views are measured and the frame is finalized. The client can use this method to adjust the scrolling border, or even to request a new layou
public static Interface Viewtreeobserver.onpredrawlistenerLet's look at the definitions in the API:class overview:The interface defined for the callback function to be executed when the view tree is about to be drawn.Common methods:Public abstract Boolean Onpredraw ()The callback function to execute when the view tree is about to be drawn. At this point all views are measured and the frame is finalized. The client can use this method to adjust the scrolling border, or even to request a new layou
1. First add a textchangedlistener to the user2. And then write a change in the text of the monitor
Copy Code code as follows:
Mobile_et.addtextchangedlistener (Textwatcher);
/**
* Real-time monitoring of user input cell phone number, enter the last one after the calculation of the amount of discount
*/
Textwatcher textwatcher = new Textwatcher () {
@Override
public void ontextchanged (charsequence s, int start, int before, int
In Android, the listening of Bluetooth device buttons is the same as the listening of general system buttons, but it only processes different keyevents. Here we will talk about the value of the previous and next keyevents sent by bluetooth,
Listen to and perform corresponding processing.
Public Boolean onkeydown (INT keycode, keyevent event) {Switch (keycode) {Case keyevent. keycode_media_next: // implement the next interface return true; Case key
nameInput: National Provincial City Company Department mailbox host name
3 Submit a certificate request file to the CA serverCA Server Configuration: 192.168.4.551 Audit Certificate Request file issue digital certificate file: Command store directory file name2 issued a digital certificate file to the Web server3 Configure the Web site service to load the private key file and the digital certificate file at run time and restart the Web site service on the site server.4 Verify the configur
These monitors include host survival, disk space monitoring, load monitoring, process Count monitoring, and ip connection monitoring. (1) define the host configuration file hosts. cfgdefinehost {host_namecacti.comaliasnagiosserveraddress192.168.10.195contact_groupsadmin on the moni
These monitors include host survival, disk space monitoring, load monitoring, process count monitoring, and ip connection monitoring.(1) define the host configuration file hosts. cfg on the Monitoring ServerDefine host {Host_name cacti.comAlias nagios serverAddress 192.168.1
Tomcat monitoring series-Introduction to monitoring tools and tomcat monitoring tools
Recently, the company's windows server has just completed Load Balancing processing for Nginx + tomcat. The next step is to monitor the background service software tomcat and nginx.What we want to achieve here is not to monitor performance and other indicators, but whether the s
Script monitoring:
Process for obtaining the maximum number of handles:
Link Analysis:
Script snippet:
Case "$ handle" in 2) echo "The handle of the process: "echo" "handle | awk '{print $3" \ n "$5" \ n "$7" \ n "$9" \ n "$11" \ n"} '> temp for I in 'cat temp' do ps-ef | grep $ I | awk' {print "{" $2 "}"": "" {"$8"} ":" "{" $15 "}"} '| grep $ I done rm-rf temp echo "five seconds later, automatically adjusts the previous page. To exit, press
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.