當前位置: 首頁>>代碼示例>>Java>>正文


Java WifiManager.createWifiLock方法代碼示例

本文整理匯總了Java中android.net.wifi.WifiManager.createWifiLock方法的典型用法代碼示例。如果您正苦於以下問題:Java WifiManager.createWifiLock方法的具體用法?Java WifiManager.createWifiLock怎麽用?Java WifiManager.createWifiLock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.net.wifi.WifiManager的用法示例。


在下文中一共展示了WifiManager.createWifiLock方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ConnectivityReceiver

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
public ConnectivityReceiver(TerminalManager manager, boolean lockingWifi) {
	mTerminalManager = manager;

	final ConnectivityManager cm =
			(ConnectivityManager) manager.getSystemService(Context.CONNECTIVITY_SERVICE);

	final WifiManager wm = (WifiManager) manager.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
	mWifiLock = wm.createWifiLock(TAG);

	final NetworkInfo info = cm.getActiveNetworkInfo();
	if (info != null) {
		mIsConnected = (info.getState() == State.CONNECTED);
	}

	mLockingWifi = lockingWifi;

	final IntentFilter filter = new IntentFilter();
	filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
	manager.registerReceiver(this, filter);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:ConnectivityReceiver.java

示例2: onCreate

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
public void onCreate(){
        super.onCreate();

        mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
        mChannel = mManager.initialize(this, getMainLooper(), null);
        mReceiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);
        mIntentFilter = new IntentFilter();
        mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
        mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
        mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
        mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);

        WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        mWiFiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL , "WiFiDirectLock");



        mHandler = new Handler();
        registerReceiver(mReceiver, mIntentFilter);
//        try {
//            Method enableP2p = WifiP2pManager.class.getMethod("enableP2p", Channel.class);
//            enableP2p.invoke(mManager, mChannel);
//        } catch (IllegalArgumentException e) {
//            e.printStackTrace();
//        } catch (IllegalAccessException e) {
//            e.printStackTrace();
//        } catch (InvocationTargetException e) {
//            e.printStackTrace();
//        } catch (NoSuchMethodException e) {
//            e.printStackTrace();
//        }
//        mManager.enableP2p(mChannel);
    }
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:34,代碼來源:FileTransferService.java

示例3: LockManager

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
public LockManager(Context context) {
  PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
  fullLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "RedPhone Full");
  partialLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RedPhone Partial");
  proximityLock = new ProximityLock(pm);

  WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
  wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "RedPhone Wifi");

  fullLock.setReferenceCounted(false);
  partialLock.setReferenceCounted(false);
  wifiLock.setReferenceCounted(false);

  accelerometerListener = new AccelerometerListener(context, new AccelerometerListener.OrientationListener() {
    @Override
    public void orientationChanged(int newOrientation) {
      orientation = newOrientation;
      Log.d(TAG, "Orentation Update: " + newOrientation);
      updateInCallLockState();
    }
  });

  wifiLockEnforced = isWifiPowerActiveModeEnabled(context);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:25,代碼來源:LockManager.java

示例4: onCreate

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
    public void onCreate() {
        super.onCreate();

        powerManager = (PowerManager) getSystemService(POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "KilimDankLock");
        wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "KilimDankWifiLock");
        createMediaPlayer();

        am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);


        mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        mTelephonyManager.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);

        // This stuff is for the broadcast receiver
        IntentFilter filter = new IntentFilter();
//        filter.addAction(AudioManager.ACTION_HEADSET_PLUG);
        filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
        registerReceiver(receiver, filter);
    }
 
開發者ID:R-a-dio,項目名稱:R-a-dio-Amazing-Android-App,代碼行數:23,代碼來源:RadioService.java

示例5: acquireWakeLocks

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
/**
 *
 */
private void acquireWakeLocks() {
    if(_wakeLock == null) {
        PowerManager powerManager = (PowerManager) getApplicationContext().getSystemService(POWER_SERVICE);
        _wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "BlockchainServiceLockTag");
    }

    if (_wifiLock == null) {
        WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        _wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, "BlockchainServiceWifiLockTag");
    }

    if (!_wakeLock.isHeld())
        _wakeLock.acquire();

    if (!_wifiLock.isHeld())
        _wifiLock.acquire();
}
 
開發者ID:ehanoc,項目名稱:xwallet,代碼行數:21,代碼來源:BlockchainService.java

示例6: onCreate

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
public void onCreate() {
    sXndroidFile = getFilesDir().getAbsolutePath() + "/xndroid_files";
    sFqHome = sXndroidFile + "/fqrouter";
    if(LogUtils.sGetDefaultLog() == null){
        LogUtils.sSetDefaultLog(new LogUtils(sXndroidFile+"/log/java_wifi.log"));
    }
    LogUtils.i("AcquireWifiLockService onCreate");
    super.onCreate();
    try {
        WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
        if (null == wifiLock) {
            wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "fqrouter wifi hotspot");
        }
        wifiLock.acquire();
        LogUtils.i("acquired wifi lock");
    } catch (Exception e) {
        LogUtils.e("failed to acquire wifi lock", e);
    }
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:21,代碼來源:AcquireWifiLockService.java

示例7: takeWifiLock

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
private void takeWifiLock() {
 //   myLog.d("Taking wifi lock");
    if (wifiLock == null) {
        WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        wifiLock = manager.createWifiLock("SwiFTP");
        wifiLock.setReferenceCounted(false);
    }
    wifiLock.acquire();
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:10,代碼來源:S_MVP.java

示例8: onStart

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
public void onStart() {
  Context appContext = getApplicationContext();
  WifiManager wifiManager = (WifiManager) appContext.getSystemService(Context.WIFI_SERVICE);
  wifiLock = wifiManager.createWifiLock(getWifiLockMode(), TAG);
  wifiLock.acquire();
  PowerManager powerManager = (PowerManager) appContext.getSystemService(Context.POWER_SERVICE);
  wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
  wakeLock.acquire();
  super.onStart();
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:12,代碼來源:HostActivity.java

示例9: onCreate

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
public void onCreate()
{
    Log.d(DEBUG_TAG, "created");
    super.onCreate();
    
    handler = new Handler();
    
    // initialise the locks
    loopMode = ConfigHelper.isLoopMode(this);
    
    // initialise the locks
    wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "RMBTWifiLock");
    wakeLock = ((PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE)).newWakeLock(
            PowerManager.PARTIAL_WAKE_LOCK, "RMBTWakeLock");
    
    // mNetworkStateIntentReceiver = new BroadcastReceiver() {
    // @Override
    // public void onReceive(Context context, Intent intent) {
    // if
    // (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION))
    // {
    //
    // final boolean connected = !
    // intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,
    // false);
    // if (! connected)
    // stopTest();
    // }
    // }
    // };
    // final IntentFilter networkStateChangedFilter = new IntentFilter();
    // networkStateChangedFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    //
    // registerReceiver(mNetworkStateIntentReceiver,
    // networkStateChangedFilter);
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:39,代碼來源:RMBTService.java

示例10: onCreate

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrefStore.setLocale(this);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    output = (TextView) findViewById(R.id.outputView);
    scroll = (ScrollView) findViewById(R.id.scrollView);

    output.setMovementMethod(LinkMovementMethod.getInstance());

    // WiFi lock init
    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, getPackageName());

    // Wake lock
    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getPackageName());

    if (EnvUtils.isLatestVersion(this)) {
        // start telnetd
        EnvUtils.execService(getBaseContext(), "telnetd", "start");
        // start httpd
        EnvUtils.execService(getBaseContext(), "httpd", "start");
    } else {
        // Update ENV
        new UpdateEnvTask(this).execute();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:42,代碼來源:MainActivity.java

示例11: createWifiLock

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
public static WifiManager.WifiLock createWifiLock(Context context, String tag)
{
	WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
	return wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, tag);
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:6,代碼來源:Util.java

示例12: acquireResources

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
/**
 * Ask to take the control of the wifi and the partial wake lock if
 * configured
 */
private synchronized void acquireResources() {
	if(holdResources) {
		return;
	}
	
	// Add a wake lock for CPU if necessary
	if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_PARTIAL_WAKE_LOCK)) {
		PowerManager pman = (PowerManager) getSystemService(Context.POWER_SERVICE);
		if (wakeLock == null) {
			wakeLock = pman.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "com.csipsimple.SipService");
			wakeLock.setReferenceCounted(false);
		}
		// Extra check if set reference counted is false ???
		if (!wakeLock.isHeld()) {
			wakeLock.acquire();
		}
	}

	// Add a lock for WIFI if necessary
	WifiManager wman = (WifiManager) getSystemService(Context.WIFI_SERVICE);
	if (wifiLock == null) {
		int mode = WifiManager.WIFI_MODE_FULL;
		if(Compatibility.isCompatible(9) && prefsWrapper.getPreferenceBooleanValue(SipConfigManager.LOCK_WIFI_PERFS)) {
			mode = 0x3; // WIFI_MODE_FULL_HIGH_PERF 
		}
		wifiLock = wman.createWifiLock(mode, "com.csipsimple.SipService");
		wifiLock.setReferenceCounted(false);
	}
	if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.LOCK_WIFI) && !wifiLock.isHeld()) {
		WifiInfo winfo = wman.getConnectionInfo();
		if (winfo != null) {
			DetailedState dstate = WifiInfo.getDetailedStateOf(winfo.getSupplicantState());
			// We assume that if obtaining ip addr, we are almost connected
			// so can keep wifi lock
			if (dstate == DetailedState.OBTAINING_IPADDR || dstate == DetailedState.CONNECTED) {
				if (!wifiLock.isHeld()) {
					wifiLock.acquire();
				}
			}
		}
	}
	holdResources = true;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:48,代碼來源:SipService.java

示例13: onCreate

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  RobotLog.writeLogcatToDisk();
  RobotLog.vv(TAG, "onCreate()");

  receivedUsbAttachmentNotifications = new ConcurrentLinkedQueue<UsbDevice>();
  eventLoop = null;

  setContentView(R.layout.activity_ftc_controller);

  context = this;
  utility = new Utility(this);
  appUtil.setThisApp(new PeerAppRobotController(context));

  entireScreenLayout = (LinearLayout) findViewById(R.id.entire_screen);
  buttonMenu = (ImageButton) findViewById(R.id.menu_buttons);
  buttonMenu.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      AppUtil.getInstance().openOptionsMenuFor(FtcRobotControllerActivity.this);
    }
  });

  BlocksOpMode.setActivityAndWebView(this, (WebView) findViewById(R.id.webViewBlocksRuntime));

  ClassManagerFactory.processClasses();
  cfgFileMgr = new RobotConfigFileManager(this);

  // Clean up 'dirty' status after a possible crash
  RobotConfigFile configFile = cfgFileMgr.getActiveConfig();
  if (configFile.isDirty()) {
    configFile.markClean();
    cfgFileMgr.setActiveConfig(false, configFile);
  }

  textDeviceName = (TextView) findViewById(R.id.textDeviceName);
  textNetworkConnectionStatus = (TextView) findViewById(R.id.textNetworkConnectionStatus);
  textRobotStatus = (TextView) findViewById(R.id.textRobotStatus);
  textOpMode = (TextView) findViewById(R.id.textOpMode);
  textErrorMessage = (TextView) findViewById(R.id.textErrorMessage);
  textGamepad[0] = (TextView) findViewById(R.id.textGamepad1);
  textGamepad[1] = (TextView) findViewById(R.id.textGamepad2);
  immersion = new ImmersiveMode(getWindow().getDecorView());
  dimmer = new Dimmer(this);
  dimmer.longBright();

  programmingModeController = new ProgrammingModeControllerImpl(
      this, (TextView) findViewById(R.id.textRemoteProgrammingMode));

  updateUI = createUpdateUI();
  callback = createUICallback(updateUI);

  PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

  WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
  wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "");

  hittingMenuButtonBrightensScreen();

  if (USE_DEVICE_EMULATION) { HardwareFactory.enableDeviceEmulation(); }

  wifiLock.acquire();
  callback.networkConnectionUpdate(WifiDirectAssistant.Event.DISCONNECTED);
  readNetworkType(NETWORK_TYPE_FILENAME);
  bindToService();
}
 
開發者ID:TheBigBombman,項目名稱:RobotIGS,代碼行數:68,代碼來源:FtcRobotControllerActivity.java

示例14: onCreate

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    // load app state
    loadAppState(getApplication());

    // set up variables
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mMediaPlayer = null;
    mPlayerInstanceCounter = 0;
    mReconnectCounter = 0;
    mStationMetadataReceived = false;
    mSession = createMediaSession(this);

    // create Wifi lock
    WifiManager wifi = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    mWifiLock = wifi.createWifiLock(WifiManager.WIFI_MODE_FULL, "Transistor_lock");

    try {
        mController = new MediaControllerCompat(getApplicationContext(), mSession.getSessionToken());
    } catch (RemoteException e) {
        LogHelper.e(LOG_TAG, "RemoteException: " + e);
        e.printStackTrace();
    }

    // RECEIVER: station metadata has changed
    BroadcastReceiver metadataChangedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.hasExtra(TransistorKeys.EXTRA_METADATA) && intent.hasExtra(TransistorKeys.EXTRA_STATION)) {

                Station station = intent.getParcelableExtra(TransistorKeys.EXTRA_STATION);
                mStationMetadata = intent.getStringExtra(TransistorKeys.EXTRA_METADATA);
                saveAppState();

                if (!mStationMetadataReceived && station.equals(mStation)) {
                    // race between onPrepared and MetadataHelper has been won by the latter
                    mStationMetadataReceived = true;
                }

                // update media session metadata
                mSession.setMetadata(getMetadata(context, station, mStationMetadata));

                // update notification
                NotificationHelper.update(mStation, mStationID_Position, mStationMetadata, mSession);
            }
        }
    };
    IntentFilter metadataChangedIntentFilter = new IntentFilter(TransistorKeys.ACTION_METADATA_CHANGED);
    LocalBroadcastManager.getInstance(this).registerReceiver(metadataChangedReceiver, metadataChangedIntentFilter);
}
 
開發者ID:malah-code,項目名稱:Open-Quran-Radio,代碼行數:53,代碼來源:PlayerService.java


注:本文中的android.net.wifi.WifiManager.createWifiLock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。