[Android] displays the intention to activate another activity
You can use the jump method similar to Java Web to realize the interface transformation
The display intention is to specify the specific information of the open component, package name, component name and component class
Create a new class twoactivity, inherit the activity class and override the oncreate() method. This method is called automatically when the interface is opened. Most initialization operations are carried out in this function, such as calling the interface and obtaining controls
Activity is an important component of the system. If the system wants to find this activity, it must be configured in the manifest file
Add a new < activity / > node,
Setting Name: Android: name = "package name. Class name"
Set the name of the intention filter < intent Filter > action as android.intent.action.main; When the name of category is android.intent.category.launcher, a shortcut icon will be created
Set icon Android: icon = ""
Set title Android: label = ""
Some of the Android system is actually an application, creating different icons to enter different interfaces.
Click the button in the first activity to jump over
Get the intent object and get it through new
Call the setclassname (packagecontext, classname) method of the intent object to set the class name. Parameters: context. Class name of string type. The full name includes the package name
Call the startactivity (intent) method of the activity object to open an activity. Parameter: intent object
The above method is a little troublesome, and Google provides a slightly convenient way
Get the intent object through new intent (packagecontext, CLS), parameters: context, class bytecode
Call the startactivity (intent) method of the activity object
Activate the interface of the system program
How to get the full interface name of the system application? Clear the logcat, start the system application on the simulator, view the log, and find the information printed by the activitymanager
Get intent object
Call the setclassname (packagename, classname) method of the intent object to set the class name. Parameters: the package name of the application string type to be activated, and the class name of the string type
Call the startactivity (intent) method
The business scenario is to automatically locate the interface of network settings when checking the network
Check the user's network condition
Get the connectitymanager object and call the getsystemservice () method of the context object. Parameter: context. Connectivity_ SERVICE
Call the getactivenetworkinfo () method of the connectitymanager object to return the networkinfo object
Call the isconnected() method of the networkinfo object
Judge whether the networkinfo object is null and the return value of the above method to show toast
Permission android.permission.access required_ NETWORK_ STATE
There will be problems with the 4.0 system. We'll talk about it later