Search in sources :

Example 11 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project facebook-android-sdk by facebook.

the class BoltsMeasurementEventListener method close.

private void close() {
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(applicationContext);
    broadcastManager.unregisterReceiver(this);
}
Also used : LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Example 12 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project facebook-android-sdk by facebook.

the class ProfileManager method getInstance.

static ProfileManager getInstance() {
    if (instance == null) {
        synchronized (ProfileManager.class) {
            if (instance == null) {
                Context applicationContext = FacebookSdk.getApplicationContext();
                LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(applicationContext);
                instance = new ProfileManager(localBroadcastManager, new ProfileCache());
            }
        }
    }
    return instance;
}
Also used : Context(android.content.Context) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Example 13 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project easy by MehdiBenmesa.

the class BaseActivity method registerReceiver.

protected void registerReceiver() {
    LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(App.REGISTRATION_PROCESS);
    intentFilter.addAction(App.MESSAGE_RECEIVED);
    bManager.registerReceiver(broadcastReceiver, intentFilter);
}
Also used : IntentFilter(android.content.IntentFilter) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Example 14 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project Bolts-Android by BoltsFramework.

the class AppLinkTest method testGeneralMeasurementEventsBroadcast.

public void testGeneralMeasurementEventsBroadcast() throws Exception {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
    i.putExtra("foo", "bar");
    ArrayList<String> arr = new ArrayList<>();
    arr.add("foo2");
    arr.add("bar2");
    i.putExtra("foobar", arr);
    Map<String, String> other = new HashMap<>();
    other.put("yetAnotherFoo", "yetAnotherBar");
    final CountDownLatch lock = new CountDownLatch(1);
    final String[] receivedStrings = new String[5];
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext());
    manager.registerReceiver(new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String eventName = intent.getStringExtra("event_name");
            Bundle eventArgs = intent.getBundleExtra("event_args");
            receivedStrings[0] = eventName;
            receivedStrings[1] = eventArgs.getString("foo");
            receivedStrings[2] = eventArgs.getString("foobar");
            receivedStrings[3] = eventArgs.getString("yetAnotherFoo");
            receivedStrings[4] = eventArgs.getString("intentData");
            lock.countDown();
        }
    }, new IntentFilter("com.parse.bolts.measurement_event"));
    MeasurementEvent.sendBroadcastEvent(getInstrumentation().getTargetContext(), "myEventName", i, other);
    lock.await(2000, TimeUnit.MILLISECONDS);
    assertEquals("myEventName", receivedStrings[0]);
    assertEquals("bar", receivedStrings[1]);
    assertEquals((new JSONArray(arr)).toString(), receivedStrings[2]);
    assertEquals("yetAnotherBar", receivedStrings[3]);
    assertEquals("http://www.example.com", receivedStrings[4]);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) HashMap(java.util.HashMap) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) Intent(android.content.Intent) CountDownLatch(java.util.concurrent.CountDownLatch) BroadcastReceiver(android.content.BroadcastReceiver) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Example 15 with LocalBroadcastManager

use of android.support.v4.content.LocalBroadcastManager in project Gadgetbridge by Freeyourgadget.

the class MiBand2Support method dispose.

@Override
public void dispose() {
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext());
    broadcastManager.unregisterReceiver(mReceiver);
    super.dispose();
}
Also used : LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager)

Aggregations

LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)36 IntentFilter (android.content.IntentFilter)15 Intent (android.content.Intent)11 Test (org.junit.Test)10 Context (android.content.Context)9 BroadcastReceiver (android.content.BroadcastReceiver)7 Bundle (android.os.Bundle)3 AccessToken (com.facebook.AccessToken)2 WaitForBroadcastReceiver (com.facebook.WaitForBroadcastReceiver)2 AppEventsLogger (com.facebook.appevents.AppEventsLogger)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Uri (android.net.Uri)1 Parcel (android.os.Parcel)1 Parcelable (android.os.Parcelable)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 RecipeList (com.se491.chef_ly.model.RecipeList)1 IOException (java.io.IOException)1 Type (java.lang.reflect.Type)1