android.app.Application.sendBroadcast()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(276)

本文整理了Java中android.app.Application.sendBroadcast()方法的一些代码示例,展示了Application.sendBroadcast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.sendBroadcast()方法的具体详情如下:
包路径:android.app.Application
类名称:Application
方法名:sendBroadcast

Application.sendBroadcast介绍

暂无

代码示例

代码示例来源:origin: bumptech/glide

void broadcast() {
  Intent connected = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
  RuntimeEnvironment.application.sendBroadcast(connected);
 }
}

代码示例来源:origin: robolectric/robolectric

@Implementation(minSdk = M)
@HiddenApi
protected void setPortRoles(
  /* UsbPort */ Object port, /* int */ Object powerRole, /* int */ Object dataRole) {
 UsbPortStatus status = usbPorts.get(port);
 usbPorts.put(
   (UsbPort) port,
   new UsbPortStatus(
     status.getCurrentMode(),
     (int) powerRole,
     (int) dataRole,
     status.getSupportedRoleCombinations()));
 application.sendBroadcast(new Intent(UsbManager.ACTION_USB_PORT_CHANGED));
}

代码示例来源:origin: google/agera

private void sendBroadcast(final Intent intent) {
 getApplication().sendBroadcast(intent);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void broadcasts_shouldBeLogged() {
 Intent broadcastIntent = new Intent("foo");
 context.sendBroadcast(broadcastIntent);
 List<Intent> broadcastIntents = shadowOf(context).getBroadcastIntents();
 assertThat(broadcastIntents).hasSize(1);
 assertThat(broadcastIntents.get(0)).isEqualTo(broadcastIntent);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void broadcastReceivers_shouldBeSharedAcrossContextsPerApplicationContext() throws Exception {
 BroadcastReceiver receiver = broadcastReceiver("Larry");
 Application application = ApplicationProvider.getApplicationContext();
 new ContextWrapper(application).registerReceiver(receiver, intentFilter("foo", "baz"));
 new ContextWrapper(application).sendBroadcast(new Intent("foo"));
 application.sendBroadcast(new Intent("baz"));
 assertThat(transcript).containsExactly("Larry notified of foo", "Larry notified of baz");
 new ContextWrapper(application).unregisterReceiver(receiver);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

@Override
public void onInstall(int result, String packageName, String version,  String src) {
  Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
  intent.setPackage(FairyGlobal.getHostApplication().getPackageName());
  intent.putExtra(EXTRA_TYPE, TYPE_INSTALL);
  intent.putExtra(EXTRA_ID, packageName);
  intent.putExtra(EXTRA_VERSION, version);
  intent.putExtra(EXTRA_RESULT_CODE, result);
  intent.putExtra(EXTRA_SRC, src);
  FairyGlobal.getHostApplication().sendBroadcast(intent);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

@Override
public void onRemove(String packageName, int code) {
  Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
  intent.setPackage(FairyGlobal.getHostApplication().getPackageName());
  intent.putExtra(EXTRA_TYPE, TYPE_REMOVE);
  intent.putExtra(EXTRA_ID, packageName);
  intent.putExtra(EXTRA_RESULT_CODE, code);
  FairyGlobal.getHostApplication().sendBroadcast(intent);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

@Override
public void onStop(String packageName) {
  Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
  intent.setPackage(FairyGlobal.getHostApplication().getPackageName());
  intent.putExtra(EXTRA_TYPE, TYPE_STOP);
  intent.putExtra(EXTRA_ID, packageName);
  FairyGlobal.getHostApplication().sendBroadcast(intent);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

@Override
public void onStart(String packageName) {
  Intent intent = new Intent(ACTION_PLUGIN_CHANGED);
  intent.setPackage(FairyGlobal.getHostApplication().getPackageName());
  intent.putExtra(EXTRA_TYPE, TYPE_START);
  intent.putExtra(EXTRA_ID, packageName);
  FairyGlobal.getHostApplication().sendBroadcast(intent);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

FairyGlobal.getHostApplication().sendBroadcast(new Intent(plugin.pluginPackageName + PluginActivityMonitor.ACTION_UN_INSTALL_PLUGIN));

代码示例来源:origin: roomanl/AndroidDownload

@Override
public void sendBroadcast(Intent intent, String receiverPermission) {
  app.sendBroadcast(intent, receiverPermission);
}

代码示例来源:origin: roomanl/AndroidDownload

@Override
public void sendBroadcast(Intent intent) {
  app.sendBroadcast(intent);
}

代码示例来源:origin: limpoxe/Android-ServiceManager

private void notifyClient(String name) {
  //通知持有服务的客户端清理缓存
  Intent intent = new Intent(ServiceManager.ACTION_SERVICE_DIE_OR_CLEAR);
  intent.putExtra(NAME, name);
  ServiceManager.sApplication.sendBroadcast(intent);
}

代码示例来源:origin: chengzichen/KrGallery

public static void addMediaToGallery(Uri uri) {
  if (uri == null) {
    return;
  }
  try {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    mediaScanIntent.setData(uri);
    applicationContext.sendBroadcast(mediaScanIntent);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: youxin11544/RxJava_Simple

public static void refreshMediaStore(File file, String fname) {
  try {
    MediaStore.Images.Media.insertImage(UtilsCollection.core.getContentResolver(), file.getAbsolutePath(), fname, null);//图片插入到系统图库
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  }
  UtilsCollection.core.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file.getAbsolutePath())));//通知图库刷新
}

代码示例来源:origin: 8enet/AppOpsX

static void sendBroadcast(Intent intent) {
 try {
  ActivityThread.currentApplication().sendBroadcast(intent);
 } catch (Exception e) {
  e.printStackTrace();
  FLog.log(e);
 }
}

代码示例来源:origin: ricknout/lens-launcher

@Override
  protected void onPostExecute(Void result) {
    AppsSingleton.getInstance().setApps(mApps);
    AppsSingleton.getInstance().setAppIcons(mAppIcons);
    Intent appsLoadedIntent = new Intent(mApplication, BroadcastReceivers.AppsLoadedReceiver.class);
    mApplication.sendBroadcast(appsLoadedIntent);
    super.onPostExecute(result);
  }
}

代码示例来源:origin: ricknout/lens-launcher

@Override
  protected void onPostExecute(Void result) {
    AppsSingleton.getInstance().setApps(mApps);
    AppsSingleton.getInstance().setAppIcons(mAppIcons);
    Intent appsLoadedIntent = new Intent(mApplication, BroadcastReceivers.AppsLoadedReceiver.class);
    mApplication.sendBroadcast(appsLoadedIntent);
    super.onPostExecute(result);
  }
}

代码示例来源:origin: org.robolectric/shadows-framework

@Implementation(minSdk = M)
@HiddenApi
protected void setPortRoles(
  /* UsbPort */ Object port, /* int */ Object powerRole, /* int */ Object dataRole) {
 UsbPortStatus status = usbPorts.get(port);
 usbPorts.put(
   (UsbPort) port,
   new UsbPortStatus(
     status.getCurrentMode(),
     (int) powerRole,
     (int) dataRole,
     status.getSupportedRoleCombinations()));
 application.sendBroadcast(new Intent(UsbManager.ACTION_USB_PORT_CHANGED));
}

代码示例来源:origin: f2prateek/rx-receivers

@Test public void wifiStateChanges() {
 Application application = RuntimeEnvironment.application;
 TestSubscriber<Integer> o = new TestSubscriber<>();
 RxWifiManager.wifiStateChanges(application).subscribe(o);
 o.assertValues();
 Intent intent1 = new Intent(WIFI_STATE_CHANGED_ACTION) //
   .putExtra(EXTRA_WIFI_STATE, WIFI_STATE_DISABLED);
 application.sendBroadcast(intent1);
 o.assertValues(WIFI_STATE_DISABLED);
 Intent intent2 = new Intent(WIFI_STATE_CHANGED_ACTION) //
   .putExtra(EXTRA_WIFI_STATE, WIFI_STATE_UNKNOWN);
 application.sendBroadcast(intent2);
 o.assertValues(WIFI_STATE_DISABLED, WIFI_STATE_UNKNOWN);
}

相关文章

微信公众号

最新文章

更多

Application类方法