Search in sources :

Example 1 with LocalBroadcastManager

use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project orgzly-android by orgzly.

the class MainActivity method onResumeFragments.

@Override
protected void onResumeFragments() {
    super.onResumeFragments();
    if (BuildConfig.LOG_DEBUG)
        LogUtils.d(TAG);
    /* Showing dialog in onResume() fails with:
         *   Can not perform this action after onSaveInstanceState
         */
    if (runnableOnResumeFragments != null) {
        runnableOnResumeFragments.run();
        runnableOnResumeFragments = null;
    }
    LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this);
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_NOTE));
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_FOLLOW_LINK_TO_NOTE_WITH_PROPERTY));
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_FOLLOW_LINK_TO_FILE));
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_SAVED_SEARCHES));
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_QUERY));
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_BOOKS));
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_BOOK));
    bm.registerReceiver(receiver, new IntentFilter(AppIntent.ACTION_OPEN_SETTINGS));
}
Also used : IntentFilter(android.content.IntentFilter) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Example 2 with LocalBroadcastManager

use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project orgzly-android by orgzly.

the class Notifications method ensureSyncNotificationSetup.

public static void ensureSyncNotificationSetup(Context context) {
    LocalBroadcastManager bm = LocalBroadcastManager.getInstance(context);
    bm.unregisterReceiver(syncServiceReceiver);
    bm.registerReceiver(syncServiceReceiver, new IntentFilter(AppIntent.ACTION_SYNC_STATUS));
}
Also used : IntentFilter(android.content.IntentFilter) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Example 3 with LocalBroadcastManager

use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project quickstart-android by firebase.

the class MainActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    updateUI(mAuth.getCurrentUser());
    // Register receiver for uploads and downloads
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
    manager.registerReceiver(mBroadcastReceiver, MyDownloadService.getIntentFilter());
    manager.registerReceiver(mBroadcastReceiver, MyUploadService.getIntentFilter());
}
Also used : LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Example 4 with LocalBroadcastManager

use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project Gadgetbridge by Freeyourgadget.

the class VescDeviceSupport method initBroadcast.

private void initBroadcast() {
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext());
    IntentFilter filter = new IntentFilter();
    filter.addAction(COMMAND_SET_RPM);
    filter.addAction(COMMAND_SET_CURRENT);
    filter.addAction(COMMAND_SET_BREAK_CURRENT);
    broadcastManager.registerReceiver(commandReceiver, filter);
}
Also used : IntentFilter(android.content.IntentFilter) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Example 5 with LocalBroadcastManager

use of androidx.localbroadcastmanager.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(instrumentation.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(instrumentation.getTargetContext(), "myEventName", i, other);
    lock.await(20000, 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(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Aggregations

LocalBroadcastManager (androidx.localbroadcastmanager.content.LocalBroadcastManager)30 IntentFilter (android.content.IntentFilter)15 BroadcastReceiver (android.content.BroadcastReceiver)9 Intent (android.content.Intent)8 Context (android.content.Context)7 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Apk (org.fdroid.fdroid.data.Apk)3 Uri (android.net.Uri)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2 Test (org.junit.Test)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 BluetoothDevice (android.bluetooth.BluetoothDevice)1 Handler (android.os.Handler)1 HandlerThread (android.os.HandlerThread)1 Message (android.os.Message)1 ScrollView (android.widget.ScrollView)1 FirebaseCrashlytics (com.google.firebase.crashlytics.FirebaseCrashlytics)1