Android WifiManager.MulticastLock - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android WifiManager.MulticastLock class.

This code example shows how to use the following methods:isHeld, release
		multicastLock.acquire();
		return multicastLock;
	} 
 
	public static void releaseMulticastLock(final MulticastLock pMulticastLock) {
		if (pMulticastLock.isHeld()) {
			pMulticastLock.release();
		} 
	} 
 
	// =========================================================== 
	// Methods 
	// =========================================================== 
 
	// =========================================================== 
	// Inner and Anonymous Classes 
	// =========================================================== 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:acquire, setReferenceCounted
		InetAddress addr = InetAddress.getByAddress( byteaddr );
		Log.d( TAG, "startProbe : wifi address=" + addr.toString() );
 
		// start multicast lock 
		mLock = wifi.createMulticastLock( "mythtv_lock" );
		mLock.setReferenceCounted( true );
		mLock.acquire();
 
		zeroConf = JmDNS.create( addr, HOSTNAME );
		zeroConf.addServiceListener( MYTHTV_FRONTEND_TYPE, this );
 
		Log.v( TAG, "startProbe : exit" );
	} 
 
	/** 
	 * @throws IOException 
	 */ 
	private void stopProbe() throws IOException { 
		Log.v( TAG, "stopProbe : enter" );
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:acquire, release, setReferenceCounted
        super.onCreate(savedInstanceState);
 
        try { 
            WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
            MulticastLock lock = wifi.createMulticastLock("wifi_multicast_lock");
            lock.setReferenceCounted(true);
            lock.acquire();
            NetworkDiscoverer.findPrinters(this);
            lock.release();
        } catch (DiscoveryException e) {
            new UIHelper(this).showErrorDialog(e.getMessage());
        } 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:acquire, isHeld, release
		if (wifiMulticastLock == null) {
			QLog.e(getClass().getName(), "Could not obtain MulticastLock!");
			return; 
		} 
 
		wifiMulticastLock.acquire();
		if (isHeld()) { 
			QLog.i(getClass().getName(), "Acquired MulticastLock!");
		} else { 
			QLog.w(getClass().getName(), "Failed to acquire MulticastLock!");
		} 
	} 
 
	public void release() { 
		if (isHeld()) { 
			QLog.i(getClass().getName(), "Releasing MulticastLock!");
			wifiMulticastLock.release();
		} 
	} 
 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isHeld, release
		super.onDestroy(); 
		if (channel != null) {
			running=false;
			channel.disconnect();
			channel.close();
			if (mcLock.isHeld()) {
				mcLock.release();
			} 
		} 
 
		textview.setText("activity destroyed");
		Toast.makeText(this, "activity destroyed", Toast.LENGTH_LONG).show();
 
	} 
 
	public void viewAccepted(View new_view) {
		// TODO Auto-generated method stub 
		System.out.println("received new view from " + new_view);
		view.setText("Received new view: " + new_view.getMembers().toString()
				+ "\n"); 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:acquire
	public synchronized static void acquireWifiMultiCastLock(Context context) {
		WifiManager wifiManager = (WifiManager) context
				.getSystemService(Context.WIFI_SERVICE);
		if (mMulticastLock == null) {
			mMulticastLock = wifiManager.createMulticastLock("multicast.test");
			mMulticastLock.acquire();
		} 
 
	} 
 
	public synchronized static void releaseWifiMultiCastLock() { 
		if (mMulticastLock != null) {
			mMulticastLock.release();
			mMulticastLock = null;
		} 
	} 
 
	public static boolean isAndroidAPNetwork(Context context) {
		String ipAddress = getLocalIpAddress();
		if (!TextUtils.isEmpty(ipAddress)
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isHeld, release
	} 
	 
    public void onDestroy(){ 
    	super.onDestroy(); 
    	ControlCenter.closeUpConnections(); 
    	if (mcLock.isHeld()) {
			mcLock.release();
		} 
		Toast.makeText(this, "Activity destroied",	Toast.LENGTH_LONG).show();
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:acquire
	 
	public static boolean openWifiBrocast(Context context){
		WifiManager wifiManager=(WifiManager)context.getSystemService(Context.WIFI_SERVICE);
		MulticastLock  multicastLock=wifiManager.createMulticastLock("Util-library");
		if (multicastLock != null){
			multicastLock.acquire();
			return true; 
		} 
		return false; 
	} 
	 
	 
	public static void setCurrentVolume(int percent,Context mc){
		AudioManager am=(AudioManager)mc.getSystemService(Context.AUDIO_SERVICE);
		int maxvolume=am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
		am.setStreamVolume(AudioManager.STREAM_MUSIC, (maxvolume*percent)/100, 
				AudioManager.FLAG_PLAY_SOUND|AudioManager.FLAG_SHOW_UI);
		am.setMode(AudioManager.MODE_INVALID);
	} 
	 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isHeld, release
	@Override 
	public void onDestroy() { 
		super.onDestroy(); 
		ControlCenter.closeUpConnections(); 
 
		if (mcLock.isHeld()) {
			mcLock.release();
		} 
		Toast.makeText(this, "Activity destroied",	Toast.LENGTH_LONG).show();
	} 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:release
 
  protected void onDestroy() { 
    mHttpServer.destroy();
    mTransmitter.destroy();
    mAvailabilityListener.destroy();
    mMulticastLock.release();
    super.onStop(); 
  } 
 
  private void loadPreferences() { 
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    mESN = settings.getString(PREFS_ATTR_UNIT_SELECTED, null);
    if (mESN != null) {
      String location = settings.getString(mESN, null);
      setTarget(mESN, location);
      return; 
    } 
    setTarget(null, null); 
  } 
 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android WifiManager.MulticastLock Questions & Answers:

See Code Examples for Android WifiManager.MulticastLock Methods: