本文整理了Java中android.content.BroadcastReceiver.onReceive()
方法的一些代码示例,展示了BroadcastReceiver.onReceive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BroadcastReceiver.onReceive()
方法的具体详情如下:
包路径:android.content.BroadcastReceiver
类名称:BroadcastReceiver
方法名:onReceive
暂无
代码示例来源:origin: robolectric/robolectric
@Override
public void run() {
receiver.onReceive(RuntimeEnvironment.application, broadcastIntent);
}
});
代码示例来源:origin: robolectric/robolectric
@Implementation
protected void onReceive(Context context, Intent intent) {
if (abort == null || !abort.get()) {
receiver.onReceive(context, intent);
}
}
代码示例来源:origin: oasisfeng/condom
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);
}
代码示例来源:origin: robolectric/robolectric
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;
}
代码示例来源:origin: android-hacker/VirtualXposed
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);
}
代码示例来源:origin: pwittchen/ReactiveNetwork
@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));
}
代码示例来源:origin: pwittchen/ReactiveNetwork
@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));
}
代码示例来源:origin: kebernet/shortyz
@Override
public void onReceive(Context ctx, Intent intent) {
impl.onReceive(ctx, intent);
}
}
代码示例来源:origin: org.robolectric/shadows-supportv4
@Override
public void run() {
receiver.onReceive(RuntimeEnvironment.application, broadcastIntent);
}
});
代码示例来源:origin: adamantoise/robocrosswords
@Override
public void onReceive(Context ctx, Intent intent) {
impl.onReceive(ctx, intent);
}
}
代码示例来源:origin: mrmaffen/vlc-android-sdk
@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);
}
}
代码示例来源:origin: wobiancao/RtspServerAndVlcPlay
@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);
}
}
代码示例来源:origin: pedroSG94/vlc-example-streamplayer
@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);
}
}
代码示例来源:origin: org.robolectric/shadows-core-v23
@Implementation
public void onReceive(Context context, Intent intent) {
if (abort == null || !abort.get()) {
receiver.onReceive(context, intent);
}
}
代码示例来源:origin: org.robolectric/shadows-core
@Implementation
public void onReceive(Context context, Intent intent) {
if (abort == null || !abort.get()) {
receiver.onReceive(context, intent);
}
}
代码示例来源:origin: org.robolectric/shadows-framework
@Implementation
protected void onReceive(Context context, Intent intent) {
if (abort == null || !abort.get()) {
receiver.onReceive(context, intent);
}
}
代码示例来源:origin: org.robolectric/framework
@Implementation
public void onReceive(Context context, Intent intent) {
if (abort == null || !abort.get()) {
receiver.onReceive(context, intent);
}
}
代码示例来源:origin: stackoverflow.com
BroadcastReceiver receiver = new YourReceiver();
receiver.onReceive(context, intent);
System.gc();
代码示例来源:origin: jenzz/RxAppState
public void notifyReceivers(@NonNull Intent intent) {
for (BroadcastReceiver receiver : receivers) {
receiver.onReceive(this, intent);
}
}
}
代码示例来源:origin: tgwizard/sls
Track sendScrobbleIntent(Intent scrobbleIntent) {
receiver.onReceive(ctx, scrobbleIntent);
return InternalTrackTransmitter.popTrack();
}
内容来源于网络,如有侵权,请联系作者删除!