Search in sources :

Example 16 with LocalBroadcastManager

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

the class Watch9DeviceSupport method dispose.

@Override
public void dispose() {
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext());
    broadcastManager.unregisterReceiver(broadcastReceiver);
    super.dispose();
}
Also used : LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Example 17 with LocalBroadcastManager

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

the class FossilHRInstallHandler method onStartInstall.

@Override
public void onStartInstall(GBDevice device) {
    DeviceCoordinator mCoordinator = DeviceHelper.getInstance().getCoordinator(device);
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(mContext);
    manager.sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_BAR).putExtra(GB.PROGRESS_BAR_INDETERMINATE, true));
    if (fossilFile.isFirmware()) {
        return;
    }
    saveAppInCache(fossilFile, null, mCoordinator, mContext);
    // refresh list
    manager.sendBroadcast(new Intent(AbstractAppManagerFragment.ACTION_REFRESH_APPLIST));
}
Also used : Intent(android.content.Intent) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager) DeviceCoordinator(nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator)

Example 18 with LocalBroadcastManager

use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project Bolts-Android by BoltsFramework.

the class AppLinkTest method testAppLinkNavInEventBroadcast.

public void testAppLinkNavInEventBroadcast() throws Exception {
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
    Bundle appLinkData = new Bundle();
    appLinkData.putString("target_url", "http://www.example2.com");
    Bundle appLinkRefererData = new Bundle();
    appLinkRefererData.putString("url", "referer://");
    appLinkRefererData.putString("app_name", "Referrer App");
    appLinkRefererData.putString("package", "com.bolts.referrer");
    appLinkData.putBundle("referer_app_link", appLinkRefererData);
    Bundle applinkExtras = new Bundle();
    applinkExtras.putString("token", "a_token");
    appLinkData.putBundle("extras", applinkExtras);
    i.putExtra("al_applink_data", appLinkData);
    final CountDownLatch lock = new CountDownLatch(1);
    final String[] receivedStrings = new String[7];
    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("targetURL");
            receivedStrings[2] = eventArgs.getString("inputURL");
            receivedStrings[3] = eventArgs.getString("refererURL");
            receivedStrings[4] = eventArgs.getString("refererAppName");
            receivedStrings[5] = eventArgs.getString("extras/token");
            receivedStrings[6] = eventArgs.getString("sourceApplication");
            lock.countDown();
        }
    }, new IntentFilter("com.parse.bolts.measurement_event"));
    Uri targetUrl = AppLinks.getTargetUrlFromInboundIntent(instrumentation.getTargetContext(), i);
    // lock.await(2000, TimeUnit.MILLISECONDS);
    lock.await();
    assertEquals("al_nav_in", receivedStrings[0]);
    assertEquals("http://www.example2.com", receivedStrings[1]);
    assertEquals("http://www.example.com", receivedStrings[2]);
    assertEquals("referer://", receivedStrings[3]);
    assertEquals("Referrer App", receivedStrings[4]);
    assertEquals("a_token", receivedStrings[5]);
    assertEquals("com.bolts.referrer", receivedStrings[6]);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Bundle(android.os.Bundle) Intent(android.content.Intent) CountDownLatch(java.util.concurrent.CountDownLatch) BroadcastReceiver(android.content.BroadcastReceiver) LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager) Uri(android.net.Uri)

Example 19 with LocalBroadcastManager

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

the class MainActivity method onPause.

@Override
protected void onPause() {
    super.onPause();
    if (BuildConfig.LOG_DEBUG)
        LogUtils.d(TAG);
    LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this);
    bm.unregisterReceiver(receiver);
    if (dialog != null) {
        dialog.dismiss();
        dialog = null;
    }
}
Also used : LocalBroadcastManager(androidx.localbroadcastmanager.content.LocalBroadcastManager)

Example 20 with LocalBroadcastManager

use of androidx.localbroadcastmanager.content.LocalBroadcastManager in project sexytopo by richsmith.

the class NewStationNotificationService method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
    broadcastManager.unregisterReceiver(receiver);
}
Also used : 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