First, PowerManager
Mainly used to control power state, set screen status, and battery standby status
PowerManager pm = ((PowerManager) Getsystemservice (Power_service));
Here I need to keep the screen awake for a long time, not being locked, so I call WakeLock .
WakeLock wake = Pm.newwakelock (Powermanager.screen_bright_wake_lock |powermanager.on_after_release, * * Activity.class);
Wake.acquire ();// Request Execution
related to flag:
Partial_wake_lock: Keep the CPU running, and the screen and keyboard lights may be off.
Screen_dim_wake_lock: Keep the CPU running, allow the screen to be displayed but may be gray, allow to turn off the keyboard light
Screen_bright_wake_lock: Keeps the CPU running, allowing the screen to be highlighted, allowing the keyboard light to be turned off
Full_wake_lock : keep the CPU Running, keep the screen highlighted, and the keyboard lights remain bright
permission to obtain :
<uses-permission android:name= "Android.permission.WAKE_LOCK"/>
Second, WindowManager
Call window, set the value of the screenbrightness parameter inside the window , but briefly set the brightness of the screen brightness, in a Activity can only take effect below.
/**
* set screen brightness
*/
private void Setwindowscreen () {
Window Localwindow = GetWindow ();
Windowmanager.layoutparams locallayoutparams = Localwindow.getattributes ();
float F = 5/255.0f;
Locallayoutparams.screenbrightness = f;
Localwindow.setattributes (Locallayoutparams);
}
get permission :
<uses-permission android:name= "Android.permission.SYSTEM_ALERT_WINDOW"/>
It is found that only in the current activity , the relevant values under the system file need to be changed to invoke the Uri(similar link) method.
/**
* save screen with minimum brightness
* Save Light State
**/
public void savebrightness (Contentresolver resolver) {
Uri uri = android.provider.Settings.System.getUriFor ("screen_brightness");
Android.provider.Settings.System.putInt (resolver, "screen_brightness", 0);
Resolver.notifychange (URI, NULL);
}
Third, Wifimanager
is the unlimited management related, similar to get wifi link name, determine whether links, switches and other and wireless related.
Wifimanager manager = (Wifimanager) context.getsystemservice (Context.wifi_service);
Wifiinfo info = Manager.getconnectioninfo ();
Wifiinfo contains a lot of things, unlimited IP, name,issid, physical address and so much more information, here I need to get to see if the link Lab wireless get wireless name, The name is SSID.
String ssId = Info.getssid ();
Manager.setwifienabled (TRUE);// turn on wifi
Manager.setwifienabled (false);// Turn off WiFi
Related permissions:
<uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name= "Android.permission.CHANGE_WIFI_STATE"/>
Four, Connectivitymanager
Primarily manages network connection related operations.
Connectivitymanager Connmanager = (Connectivitymanager)
Context.getsystemservice (Context.connectivity_service);
Networkinfo NetInfo = Connmanager.getnetworkinfo (Connectivitymanager.type_wifi)
Networkinfo contains information about the network connection, including the connection status, whether the network is available, and other related operations
int code = netinfo.getstate ();
if (wifistate = = State.connected | | wifistate = = state.connecting)
Return 200;// Connection succeeded
Else
return 500; Connection Failed
Related permissions:
<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/>
Five, Activitymanager
are all running in the system. Activity Interaction provides an interface, the main interface around the running process information, task information, service information and so on.
Activitymanager am = (activitymanager) this.getsystemservice (Activity_service);
Memoryinfo mi = new Memoryinfo ();
Am.getmemoryinfo (MI);
Am.getrunningappprocesses ();
Am.getrunningservices ();
Am.getdeviceconfigurationinfo ();
Am.killbackgroundprocessed (PackageName);
Am.restartpackage (PackageName);
Android various manager-Guo Tong