congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Context.sendBroadcast
Code IndexAdd Tabnine to your IDE (free)

How to use
sendBroadcast
method
in
android.content.Context

Best Java code snippets using android.content.Context.sendBroadcast (Showing top 20 results out of 2,907)

origin: stackoverflow.com

 // This function will create an intent. This intent must take as parameter the "unique_name" that you registered your activity with
static void updateMyActivity(Context context, String message) {

  Intent intent = new Intent("unique_name");

  //put whatever data you want to send, if any
  intent.putExtra("message", message);

  //send broadcast
  context.sendBroadcast(intent);
}
origin: k9mail/k-9

public static void set(Context context, Intent broadcastIntent) {
  broadcastIntent.setAction(K9RemoteControl.K9_SET);
  context.sendBroadcast(broadcastIntent, K9RemoteControl.K9_REMOTE_CONTROL_PERMISSION);
}
origin: chentao0707/SimplifyReader

public static void checkNetworkState(Context mContext) {
  Intent intent = new Intent();
  intent.setAction(CUSTOM_ANDROID_NET_CHANGE_ACTION);
  mContext.sendBroadcast(intent);
}
origin: jeasonlzy/ImagePicker

/**
 * 扫描图片
 */
public static void galleryAddPic(Context context, File file) {
  Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
  Uri contentUri = Uri.fromFile(file);
  mediaScanIntent.setData(contentUri);
  context.sendBroadcast(mediaScanIntent);
}
origin: leolin310148/ShortcutBadger

@Override
public void executeBadge(Context context, ComponentName componentName, int badgeCount) throws ShortcutBadgeException {
  Intent intent = new Intent("launcher.action.CHANGE_APPLICATION_NOTIFICATION_NUM");
  intent.putExtra("packageName", context.getPackageName());
  intent.putExtra("className", componentName.getClassName());
  intent.putExtra("notificationNum", badgeCount);
  context.sendBroadcast(intent);
}
origin: aa112901/remusic

  @Override
  public void onReceive(Context context, Intent intent) {

//        if (MusicPlayer.isPlaying()) {
    Intent activityIntent = new Intent(context.getApplicationContext(), PlayingActivity.class);
    activityIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
    context.getApplicationContext().startActivity(activityIntent);
    Intent intent1 = new Intent();
    intent1.setComponent(new ComponentName("com.wm.remusic", "com.wm.remusic.activity.PlayingActivity.class"));
    context.sendBroadcast(intent1);
//        }

  }

origin: leolin310148/ShortcutBadger

private static void executeBadgeByBroadcast(Context context, ComponentName componentName,
                      int badgeCount) {
  Intent intent = new Intent(INTENT_ACTION);
  intent.putExtra(INTENT_EXTRA_PACKAGE_NAME, componentName.getPackageName());
  intent.putExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.getClassName());
  intent.putExtra(INTENT_EXTRA_MESSAGE, String.valueOf(badgeCount));
  intent.putExtra(INTENT_EXTRA_SHOW_MESSAGE, badgeCount > 0);
  context.sendBroadcast(intent);
}
origin: android-hacker/VirtualXposed

  @Override
  public void onReceive(Context context, Intent intent) {
        Intent realIntent = intent.getParcelableExtra("_VA_|_intent_");
    int userId = intent.getIntExtra("_VA_|_user_id_", VUserHandle.USER_ALL);
    if (realIntent != null) {
      Intent newIntent = ComponentUtils.redirectBroadcastIntent(realIntent, userId);
      if (newIntent != null) {
        context.sendBroadcast(newIntent);
      }
    }
  }
}
origin: TeamNewPipe/NewPipe

@Override
public void onAudioSessionId(int i) {
  if (!PlayerHelper.isUsingDSP(context)) return;
  final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
  intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, i);
  intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, context.getPackageName());
  context.sendBroadcast(intent);
}
origin: k9mail/k-9

  public static void releaseWakeLock(Context context, int wakeLockId) {
    Timber.v("CoreReceiver Got request to release wakeLock %d", wakeLockId);

    Intent i = new Intent();
    i.setClass(context, CoreReceiver.class);
    i.setAction(WAKE_LOCK_RELEASE);
    i.putExtra(WAKE_LOCK_ID, wakeLockId);
    context.sendBroadcast(i);
  }
}
origin: commonsguy/cw-omnibus

 private static void sendImplicitBroadcast(Context ctxt, Intent i) {
  PackageManager pm=ctxt.getPackageManager();
  List<ResolveInfo> matches=pm.queryBroadcastReceivers(i, 0);

  for (ResolveInfo resolveInfo : matches) {
   Intent explicit=new Intent(i);
   ComponentName cn=
    new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName,
     resolveInfo.activityInfo.name);

   explicit.setComponent(cn);
   ctxt.sendBroadcast(explicit);
  }
 }
}
origin: lingochamp/FileDownloader

  public static void sendCompletedBroadcast(FileDownloadModel model) {
    if (model == null) throw new IllegalArgumentException();
    if (model.getStatus() != FileDownloadStatus.completed) throw new IllegalStateException();

    final Intent intent = new Intent(ACTION_COMPLETED);
    intent.putExtra(KEY_MODEL, model);

    FileDownloadHelper.getAppContext().sendBroadcast(intent);
  }
}
origin: android-hacker/VirtualXposed

  @Override
  public void notifyBadgerChange(BadgerInfo info) throws RemoteException {
    Intent intent = new Intent(VASettings.ACTION_BADGER_CHANGE);
    intent.putExtra("userId", info.userId);
    intent.putExtra("packageName", info.packageName);
    intent.putExtra("badgerCount", info.badgerCount);
    VirtualCore.get().getContext().sendBroadcast(intent);
  }
}
origin: k9mail/k-9

public static void triggerMessageListWidgetUpdate(Context context) {
  Context appContext = context.getApplicationContext();
  AppWidgetManager widgetManager = AppWidgetManager.getInstance(appContext);
  ComponentName widget = new ComponentName(appContext, MessageListWidgetProvider.class);
  int[] widgetIds = widgetManager.getAppWidgetIds(widget);
  Intent intent = new Intent(context, MessageListWidgetProvider.class);
  intent.setAction(ACTION_UPDATE_MESSAGE_LIST);
  intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
  context.sendBroadcast(intent);
}
origin: leolin310148/ShortcutBadger

public static void sendIntentExplicitly(Context context, Intent intent) throws ShortcutBadgeException {
  List<ResolveInfo> resolveInfos = resolveBroadcast(context, intent);
  if (resolveInfos.size() == 0) {
    throw new ShortcutBadgeException("unable to resolve intent: " + intent.toString());
  }
  for (ResolveInfo info : resolveInfos) {
    Intent actualIntent = new Intent(intent);
    if (info != null) {
      actualIntent.setPackage(info.resolvePackageName);
      context.sendBroadcast(actualIntent);
    }
  }
}
origin: android-hacker/VirtualXposed

public void sendBroadcastAsUser(Intent intent, VUserHandle user) {
  SpecialComponentList.protectIntent(intent);
  Context context = VirtualCore.get().getContext();
  if (user != null) {
    intent.putExtra("_VA_|_user_id_", user.getIdentifier());
  }
  context.sendBroadcast(intent);
}
origin: android-hacker/VirtualXposed

public void sendBroadcast(Intent intent, int userId) {
  Intent newIntent = ComponentUtils.redirectBroadcastIntent(intent, userId);
  if (newIntent != null) {
    VirtualCore.get().getContext().sendBroadcast(newIntent);
  }
}
origin: android-hacker/VirtualXposed

public void sendBroadcastAsUser(Intent intent, VUserHandle user, String permission) {
  SpecialComponentList.protectIntent(intent);
  Context context = VirtualCore.get().getContext();
  if (user != null) {
    intent.putExtra("_VA_|_user_id_", user.getIdentifier());
  }
  // TODO: checkPermission
  context.sendBroadcast(intent);
}
origin: TeamNewPipe/NewPipe

@Override
public boolean onPlayerOptionSelected(MenuItem item) {
  if (item.getItemId() == R.id.action_switch_background) {
    this.player.setRecovery();
    getApplicationContext().sendBroadcast(getPlayerShutdownIntent());
    getApplicationContext().startService(getSwitchIntent(BackgroundPlayer.class));
    return true;
  }
  return false;
}
origin: TeamNewPipe/NewPipe

@Override
public boolean onPlayerOptionSelected(MenuItem item) {
  if (item.getItemId() == R.id.action_switch_popup) {
    if (!PermissionHelper.isPopupEnabled(this)) {
      PermissionHelper.showPopupEnablementToast(this);
      return true;
    }
    this.player.setRecovery();
    getApplicationContext().sendBroadcast(getPlayerShutdownIntent());
    getApplicationContext().startService(getSwitchIntent(PopupVideoPlayer.class));
    return true;
  }
  return false;
}
android.contentContextsendBroadcast

Popular methods of Context

  • getPackageName
  • getResources
  • getSystemService
  • obtainStyledAttributes
  • getApplicationContext
  • getString
  • getPackageManager
  • startActivity
  • getContentResolver
  • getSharedPreferences
  • getAssets
  • getTheme
  • getAssets,
  • getTheme,
  • getCacheDir,
  • startService,
  • getFilesDir,
  • registerReceiver,
  • getApplicationInfo,
  • unregisterReceiver,
  • getExternalCacheDir

Popular in Java

  • Finding current android device location
  • getResourceAsStream (ClassLoader)
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now