当前位置: 首页>>代码示例>>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;未经允许,请勿转载。