List of usage examples for android.content Context sendBroadcast
public abstract void sendBroadcast(@RequiresPermission Intent intent);
From source file:in.myfootprint.myfootprint.push.MyGCMListenerService.java
static void updateMyActivity(Context context, int messageNumber) { Intent intent = new Intent("unique_name"); /*Gson gson = new Gson(); // This can be any object. Does not have to be an arraylist. String json = gson.toJson(messageList);*/ int prevValue = PrefUtilsNew.getNotifNumber(); int newValue = prevValue + messageNumber; PrefUtilsNew.setNotifNumber(newValue); Log.e("Khudka", String.valueOf(newValue)); //put whatever data you want to send, if any //intent.putExtra("message", messageNo); //send broadcast context.sendBroadcast(intent); }
From source file:com.smarthome.deskclock.Alarms.java
/** * Tells the StatusBar whether the alarm is enabled or disabled *///from w ww .jav a2 s. c o m private static void setStatusBarIcon(Context context, boolean enabled) { Intent alarmChanged = new Intent("android.intent.action.ALARM_CHANGED"); alarmChanged.putExtra("alarmSet", enabled); context.sendBroadcast(alarmChanged); }
From source file:Main.java
private static void setBadgeSony(Context context, int count) { String launcherClassName = getLauncherClassName(context); if (launcherClassName == null) { return;/*from w w w . j a v a2 s. c o m*/ } Intent intent = new Intent(); intent.setAction("com.sonyericsson.home.action.UPDATE_BADGE"); intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", launcherClassName); intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true); intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", String.valueOf(count)); intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", context.getPackageName()); context.sendBroadcast(intent); }
From source file:Main.java
private static void clearBadgeSony(Context context) { String launcherClassName = getLauncherClassName(context); if (launcherClassName == null) { return;// w w w . j av a2s. c om } Intent intent = new Intent(); intent.setAction("com.sonyericsson.home.action.UPDATE_BADGE"); intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", launcherClassName); intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", false); intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", String.valueOf(0)); intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", context.getPackageName()); context.sendBroadcast(intent); }
From source file:Main.java
public static void createDeskShortCut(Context cxt, String shortCutName, int icon, Class<?> cls) { Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortcutIntent.putExtra("duplicate", false); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortCutName); Parcelable ico = Intent.ShortcutIconResource.fromContext(cxt.getApplicationContext(), icon); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ico); Intent intent = new Intent(cxt, cls); intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); cxt.sendBroadcast(shortcutIntent); }
From source file:org.sufficientlysecure.keychain.network.orbot.OrbotHelper.java
/** * First, checks whether Orbot is installed. If Orbot is installed, then a * broadcast {@link Intent} is sent to request Orbot to start transparently * in the background. When Orbot receives this {@code Intent}, it will * immediately reply to this all with its status via an * {@link #ACTION_STATUS} {@code Intent} that is broadcast to the * {@code packageName} of the provided {@link Context} (i.e. * {@link Context#getPackageName()}.// w ww. j a v a2 s . co m * * @param context the app {@link Context} will receive the reply * @return whether the start request was sent to Orbot */ public static boolean requestStartTor(Context context) { if (OrbotHelper.isOrbotInstalled(context)) { Log.i("OrbotHelper", "requestStartTor " + context.getPackageName()); Intent intent = getOrbotStartIntent(); intent.putExtra(EXTRA_PACKAGE_NAME, context.getPackageName()); context.sendBroadcast(intent); return true; } return false; }
From source file:com.lcl6.cn.imagepickerl.AndroidImagePicker.java
/** * scan the photo so that the gallery can read it * @param ctx//from w ww . java2 s .c o m * @param path */ public static void galleryAddPic(Context ctx, String path) { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); File f = new File(path); Uri contentUri = Uri.fromFile(f); mediaScanIntent.setData(contentUri); ctx.sendBroadcast(mediaScanIntent); Log.i(TAG, "=====MediaScan:" + path); }
From source file:com.google.android.apps.santatracker.SantaNotificationBuilder.java
/** * Dismiss all notifications.//from ww w . j a v a 2 s. c om */ public static void DismissNotifications(Context c) { NotificationManager mNotificationManager = (NotificationManager) c .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancelAll(); // Send a broadcast to the phone's service, so it will update the data API to // let the watch know to cancel all its corresponding notifications. Intent dismissWearableNotifications = new Intent(c, PhoneNotificationService.class); dismissWearableNotifications.setAction(NotificationConstants.ACTION_DISMISS); c.sendBroadcast(dismissWearableNotifications); }
From source file:org.klnusbaum.udj.network.RESTProcessor.java
private static void checkPlaybackState(Context context, AccountManager am, Account account, String playbackState) {//from w w w.j av a 2 s .c o m int plState = Constants.PLAYING_STATE; if (playbackState.equals("playing")) { plState = Constants.PLAYING_STATE; } else if (playbackState.equals("paused")) { plState = Constants.PAUSED_STATE; } if (Utils.getPlaybackState(am, account) != plState) { am.setUserData(account, Constants.PLAYBACK_STATE_DATA, String.valueOf(plState)); Intent playbackStateChangedBroadcast = new Intent(Constants.BROADCAST_PLAYBACK_CHANGED); playbackStateChangedBroadcast.putExtra(Constants.PLAYBACK_STATE_EXTRA, plState); context.sendBroadcast(playbackStateChangedBroadcast); } }
From source file:org.restcomm.app.utillib.Utils.Global.java
public static void startService(Context context, boolean bUI) { String packagename = context.getPackageName(); // See if this app is yeilded to another app if (bUI) {//from ww w .ja v a 2s . c o m PreferenceManager.getDefaultSharedPreferences(context).edit() .putString(PreferenceKeys.Miscellaneous.YEILDED_SERVICE, packagename).commit(); Intent intent = new Intent(CommonIntentActionsOld.ACTION_START_UI); intent.putExtra("packagename", packagename); context.sendBroadcast(intent); } if (!isServiceYeilded(context)) { Intent bgServiceIntent = new Intent(); //bgServiceIntent.setComponent(new ComponentName(context.getPackageName(), "com.cortxt.app.corelib.MainService")); bgServiceIntent.setComponent( new ComponentName(context.getPackageName(), "org.restcomm.app.qoslib.MainService")); LoggerUtil.logToFile(LoggerUtil.Level.ERROR, "Global", "isServiceYeilded", "MMC Service started for " + packagename); context.startService(bgServiceIntent); } }