@Override public void run() { receiver.onReceive(RuntimeEnvironment.application, broadcastIntent); } });
@Implementation protected void onReceive(Context context, Intent intent) { if (abort == null || !abort.get()) { receiver.onReceive(context, intent); } }
void proceedBroadcast(final Context context, final Intent intent, final WrappedValueProcedure<Boolean> procedure, final @Nullable BroadcastReceiver resultReceiver) { if (proceed(OutboundType.BROADCAST, intent, Boolean.FALSE, procedure) == Boolean.FALSE && resultReceiver != null) resultReceiver.onReceive(new ReceiverRestrictedContext(context), intent); }
private Intent processStickyIntents( IntentFilter filter, BroadcastReceiver receiver, Context context) { Intent result = null; for (Intent stickyIntent : stickyIntents.values()) { if (filter.matchAction(stickyIntent.getAction())) { if (result == null) { result = stickyIntent; } if (receiver != null) { receiver.setPendingResult(ShadowBroadcastPendingResult.createSticky(stickyIntent)); receiver.onReceive(context, stickyIntent); receiver.setPendingResult(null); } else if (result != null) { break; } } } return result; }
private void handleReceiver(ReceiverData data) { BroadcastReceiver.PendingResult result = data.resultData.build(); try { if (!isBound()) { bindApplication(data.component.getPackageName(), data.processName); } Context context = mInitialApplication.getBaseContext(); Context receiverContext = ContextImpl.getReceiverRestrictedContext.call(context); String className = data.component.getClassName(); BroadcastReceiver receiver = (BroadcastReceiver) context.getClassLoader().loadClass(className).newInstance(); mirror.android.content.BroadcastReceiver.setPendingResult.call(receiver, result); data.intent.setExtrasClassLoader(context.getClassLoader()); if (data.intent.getComponent() == null) { data.intent.setComponent(data.component); } receiver.onReceive(receiverContext, data.intent); if (mirror.android.content.BroadcastReceiver.getPendingResult.call(receiver) != null) { result.finish(); } } catch (Exception e) { // must be this for misjudge of anti-virus!! throw new RuntimeException(String.format("Unable to start receiver: %s ", data.component), e); } VActivityManager.get().broadcastFinish(data.resultData); }
@Test public void shouldReceiveIntentWhenIsNotInIdleMode() { // given preparePowerManagerMocks(Boolean.FALSE, Boolean.FALSE); BroadcastReceiver broadcastReceiver = strategy.createIdleBroadcastReceiver(); // when broadcastReceiver.onReceive(contextMock, intent); // then verify(strategy).onNext(any(Connectivity.class)); }
@Test public void shouldReceiveIntentInIdleMode() { // given preparePowerManagerMocks(Boolean.TRUE, Boolean.FALSE); BroadcastReceiver broadcastReceiver = strategy.createIdleBroadcastReceiver(); // when broadcastReceiver.onReceive(contextMock, intent); // then verify(strategy).onNext(any(Connectivity.class)); }
@Override public void onReceive(Context ctx, Intent intent) { impl.onReceive(ctx, intent); } }
@Override public void run() { receiver.onReceive(RuntimeEnvironment.application, broadcastIntent); } });
@Override public void onReceive(Context ctx, Intent intent) { impl.onReceive(ctx, intent); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void registerAudioPlugV21(boolean register) { if (register) { final IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_HDMI_AUDIO_PLUG); final Intent stickyIntent = mLibVLC.mAppContext.registerReceiver(mAudioPlugReceiver, intentFilter); if (stickyIntent != null) mAudioPlugReceiver.onReceive(mLibVLC.mAppContext, stickyIntent); } else { mLibVLC.mAppContext.unregisterReceiver(mAudioPlugReceiver); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void registerAudioPlugV21(boolean register) { if (register) { final IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_HDMI_AUDIO_PLUG); final Intent stickyIntent = mLibVLC.mAppContext.registerReceiver(mAudioPlugReceiver, intentFilter); if (stickyIntent != null) mAudioPlugReceiver.onReceive(mLibVLC.mAppContext, stickyIntent); } else { mLibVLC.mAppContext.unregisterReceiver(mAudioPlugReceiver); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void registerAudioPlugV21(boolean register) { if (register) { final IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_HDMI_AUDIO_PLUG); final Intent stickyIntent = mLibVLC.mAppContext.registerReceiver(mAudioPlugReceiver, intentFilter); if (stickyIntent != null) mAudioPlugReceiver.onReceive(mLibVLC.mAppContext, stickyIntent); } else { mLibVLC.mAppContext.unregisterReceiver(mAudioPlugReceiver); } }
@Implementation public void onReceive(Context context, Intent intent) { if (abort == null || !abort.get()) { receiver.onReceive(context, intent); } }
@Implementation public void onReceive(Context context, Intent intent) { if (abort == null || !abort.get()) { receiver.onReceive(context, intent); } }
@Implementation protected void onReceive(Context context, Intent intent) { if (abort == null || !abort.get()) { receiver.onReceive(context, intent); } }
@Implementation public void onReceive(Context context, Intent intent) { if (abort == null || !abort.get()) { receiver.onReceive(context, intent); } }
BroadcastReceiver receiver = new YourReceiver(); receiver.onReceive(context, intent); System.gc();
public void notifyReceivers(@NonNull Intent intent) { for (BroadcastReceiver receiver : receivers) { receiver.onReceive(this, intent); } } }
Track sendScrobbleIntent(Intent scrobbleIntent) { receiver.onReceive(ctx, scrobbleIntent); return InternalTrackTransmitter.popTrack(); }