List of usage examples for android.support.v4.content LocalBroadcastManager getInstance
public static LocalBroadcastManager getInstance(Context context)
From source file:Main.java
public static void unRegisterBroadcast(Context context, BroadcastReceiver receiver) { if (context != null && receiver != null) { try {/*ww w.j av a 2 s. co m*/ // context.unregisterReceiver(receiver); LocalBroadcastManager.getInstance(context).unregisterReceiver(receiver); } catch (IllegalArgumentException e) { } } }
From source file:at.ac.uniklu.mobile.sportal.util.LocalBroadcastCommunicator.java
private static <T> void unregisterReceiver(LocalBroadcastCommunicator receiver, Context context) { LocalBroadcastManager.getInstance(context).unregisterReceiver(receiver); }
From source file:com.android.tv.settings.name.DeviceManager.java
/** * Sets the system device name.//from www . j a v a 2 s.c o m * * For now it will explicitly call the different discoverable services that haven't been ported * to use the Settings.Global.DEVICE_NAME entry. * * @param context A context that can access Settings.Global * @param name The new device name. */ public static void setDeviceName(Context context, String name) { Settings.Global.putString(context.getContentResolver(), Settings.Global.DEVICE_NAME, name); BluetoothAdapter.getDefaultAdapter().setName(name); LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ACTION_DEVICE_NAME_UPDATE)); }
From source file:alaindc.crowdroid.RadioUtils.java
public static String[] getWifiInfo(Context context) { try {/*from w w w . j a v a2 s .c o m*/ WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiMan.getConnectionInfo(); String bssid = wifiInfo.getBSSID(); String ssid = wifiInfo.getSSID(); String signalStrength = String.valueOf(wifiInfo.getRssi()); // Update view Intent senseintent = new Intent(Constants.INTENT_UPDATE_SENSORS); senseintent.putExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA, ssid + " " + signalStrength); LocalBroadcastManager.getInstance(context).sendBroadcast(senseintent); return new String[] { bssid, ssid, signalStrength }; } catch (Exception e) { return new String[] { "", "", "" }; } }
From source file:at.ac.uniklu.mobile.sportal.util.LocalBroadcastCommunicator.java
public static void sendBroadcast(Context context, Intent intent) { if (sAction == null) { /* If sAction is null at this point, no receiver has been registered yet and there's no * point in sending a broadcast. */ return;//from w w w .j av a2s .c om } intent.setAction(sAction); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); }
From source file:com.amlcurran.messages.events.BroadcastEventBus.java
public BroadcastEventBus(Context context) { broadcaster = LocalBroadcastManager.getInstance(context); }
From source file:Main.java
/** * Rudimentary methods wrapping the use of a LocalBroadcastManager to simplify the process * of notifying other classes when a particular fragment is notified that a permission is * granted.// w ww . j a v a2s . co m * * To be notified when a permission has been granted, create a new broadcast receiver * and register it using {@link #registerPermissionReceiver(Context, BroadcastReceiver, String)} * * E.g. * * final BroadcastReceiver receiver = new BroadcastReceiver() { * @Override * public void onReceive(Context context, Intent intent) { * refreshContactsView(); * } * } * * PermissionsUtil.registerPermissionReceiver(getActivity(), receiver, READ_CONTACTS); * * If you register to listen for multiple permissions, you can identify which permission was * granted by inspecting {@link Intent#getAction()}. * * In the fragment that requests for the permission, be sure to call * {@link #notifyPermissionGranted(Context, String)} when the permission is granted so that * any interested listeners are notified of the change. */ public static void registerPermissionReceiver(Context context, BroadcastReceiver receiver, String permission) { final IntentFilter filter = new IntentFilter(permission); LocalBroadcastManager.getInstance(context).registerReceiver(receiver, filter); }
From source file:com.antew.redditinpictures.library.reddit.SubscribeResponse.java
@Override public void processHttpResponse(Context context) { Ln.i("Got back from subscribe! = %s", Strings.toString(result.getJson())); LocalBroadcastManager.getInstance(context) .sendBroadcast(new Intent(Constants.Broadcast.BROADCAST_SUBSCRIBE)); }
From source file:ac.robinson.bettertogether.api.messaging.PluginMessageReceiver.java
@Override public void onReceive(Context context, android.content.Intent intent) { switch (intent.getAction()) { case PluginIntent.ACTION_STOP_PLUGIN: LocalBroadcastManager.getInstance(context).sendBroadcast(intent); break;/*from w w w .j a v a 2s .c om*/ case PluginIntent.ACTION_MESSAGE_RECEIVED: LocalBroadcastManager.getInstance(context).sendBroadcast(intent); break; default: break; } }
From source file:arun.com.chromer.util.ServiceManager.java
public static void refreshCustomTabBindings(@NonNull Context context) { final Intent intent = new Intent(Constants.ACTION_REBIND_WEBHEAD_TAB_CONNECTION); intent.putExtra(Constants.EXTRA_KEY_REBIND_WEBHEAD_CXN, true); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); }