Home > Mobile >  Android wifi lock problem
Android wifi lock problem

Time:09-17

Run run ww. Text1 (normal), ww. AcquireWifiLock (); Black screen, solving.


Package com. Mycompany. Myapp;

The import android. App. *;
The import android. OS. *;

The import android.net.wifi.ScanResult;
The import android.net.wifi.WifiConfiguration;
The import android.net.wifi.WifiInfo;
The import android.net.wifi.WifiManager;
The import android.net.wifi.WifiManager.WifiLock;
The import android. Widget. Toast;
The import android. Widget. The Button;
The import android. View. The view. *;
The import android. View. *;
The import android. Media. *;
The import android. Content. *;
Public class MainActivity extends the Activity
{
Public class WifiLocKManager {
//object definition WifiManager
Private WifiManager mWifiManager;
Private WifiManager. WifiLock mWifiLock;
Public WifiLocKManager Context (Context) {
//object WifiManager
MWifiManager=(WifiManager) context. GetSystemService (context. WIFI_SERVICE);
}
Public void creatWifiLock (String locakName) {
MWifiLock=mWifiManager. CreateWifiLock (" Test ");
}
//lock WifiLock
Public void acquireWifiLock () {
MWifiLock. Acquire ();
}
//test
Public void text1 () {
Toast. MakeText (MainActivity. This IS "OK", Toast. LENGTH_LONG), show ();
}
}
@ Override
Protected void onCreate (Bundle savedInstanceState)
{
Super. OnCreate (savedInstanceState);
The setContentView (R.l ayout. Main);
WifiLocKManager ww=new WifiLocKManager (this);
Ww. AcquireWifiLock ();
Ww. Text1 ();
}
}
  • Related