Example usage for android.content Context startService

List of usage examples for android.content Context startService

Introduction

In this page you can find the example usage for android.content Context startService.

Prototype

@Nullable
public abstract ComponentName startService(Intent service);

Source Link

Document

Request that a given application service be started.

Usage

From source file:com.tealeaf.PushBroadcastReceiver.java

@Override
public void onReceive(final Context context, Intent in) {
    final TeaLeafOptions options = new TeaLeafOptions(context);
    final String appID = options.getAppID();

    if (!appID.equals(in.getStringExtra("appID"))) {
        return;/*ww w. java 2  s .c o m*/
    }
    scheduledIntent = null;

    new Thread(new Runnable() {
        public void run() {
            HTTP http = new HTTP();
            Settings settings = new Settings(context);
            String format = options.getPushUrl();
            String url = String.format(format, appID, Device.getDeviceID(context, settings),
                    options.getBuildIdentifier());

            logger.log("{push} Polling for notifications on", url);
            Pair<String, Integer> result = http.getPush(URI.create(url));
            int timeout = options.getPushDelay();
            if (result != null) {
                timeout = result.second;
                if (timeout == -1) {
                    timeout = options.getPushDelay();
                }
                String json = result.first;
                logger.log("{push} Got push notification", json, "and will delay for", timeout,
                        "seconds before checking again");

                try {
                    JSONArray array = new JSONArray(json);
                    int len = array.length();
                    JSONArray notifications = new JSONArray(settings.getPushNotifications());

                    for (int i = 0; i < len; i++) {
                        JSONObject msg = array.getJSONObject(i);
                        if (msg.optBoolean("crossPromo", false)) {
                            // a cross-promo
                            Intent intent = new Intent("com.tealeaf.CROSS_PROMO");
                            intent.putExtra("appid", msg.getString("appID"));
                            intent.putExtra("url", msg.getString("url"));
                            intent.putExtra("version", msg.getString("version"));
                            intent.putExtra("displayName", msg.getString("displayName"));
                            intent.putExtra("buildID", msg.getString("buildIdentifier"));
                            intent.putExtra("image", msg.optString("image"));
                            context.startService(intent);
                        } else if (msg.optBoolean("hasUpdate", false) && !settings.is("updating_now")) {
                            logger.log("{push} Got an update request (old build id:",
                                    options.getBuildIdentifier(), ", new build identifier:",
                                    msg.getString("buildIdentifier"), ", old android version:",
                                    options.getGameHash(), ", new android version:", msg.getString("gameHash"),
                                    ")");
                            // an update notification
                            Intent intent = new Intent("com.tealeaf.PERFORM_UPDATE");
                            // required parameters
                            // is the update supposed to be silent?
                            intent.putExtra("silent", msg.getBoolean("silent"));
                            // does the update require hitting the marketplace instead? (native runtime update)
                            intent.putExtra("market", !msg.getString("gameHash").equals(options.getGameHash()));
                            // what's the new build identifier of the update?
                            intent.putExtra("buildIdentifier", msg.getString("buildIdentifier"));
                            // what url can I download the updated build from?
                            intent.putExtra("url", msg.getString("url"));
                            context.sendOrderedBroadcast(intent, null);
                        }
                    }
                    settings.setPushNotifications(notifications.toString());
                } catch (JSONException e) {
                    logger.log(e);
                }
            }
            scheduleNext(context, timeout);
        }
    }).start();
}

From source file:org.kontalk.service.msgcenter.MessageCenterService.java

public static void retryMessage(final Context context, Uri uri, boolean chatEncryptionEnabled) {
    boolean encrypted = Preferences.getEncryptionEnabled(context) && chatEncryptionEnabled;
    MessagesProviderUtils.retryMessage(context, uri, encrypted);
    Intent i = new Intent(context, MessageCenterService.class);
    i.setAction(MessageCenterService.ACTION_RETRY);
    // TODO not implemented yet
    i.putExtra(MessageCenterService.EXTRA_MESSAGE, uri);
    context.startService(i);
}

From source file:org.kontalk.service.msgcenter.MessageCenterService.java

/** Sends a text message. */
public static void sendTextMessage(final Context context, String to, String text, boolean encrypt, long msgId,
        String packetId) {// www  . j  a v  a2s . c o m
    Intent i = new Intent(context, MessageCenterService.class);
    i.setAction(MessageCenterService.ACTION_MESSAGE);
    i.putExtra("org.kontalk.message.msgId", msgId);
    i.putExtra("org.kontalk.message.packetId", packetId);
    i.putExtra("org.kontalk.message.mime", TextComponent.MIME_TYPE);
    i.putExtra("org.kontalk.message.to", to);
    i.putExtra("org.kontalk.message.body", text);
    i.putExtra("org.kontalk.message.encrypt", encrypt);
    i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
    context.startService(i);
}

From source file:com.cerema.cloud2.files.InstantUploadBroadcastReceiver.java

private void handleNewPictureAction(Context context, Intent intent) {
    Cursor c = null;/*from ww  w  .  j  a  va2s.  c o m*/
    String file_path = null;
    String file_name = null;
    String mime_type = null;

    Log_OC.w(TAG, "New photo received");

    if (!instantPictureUploadEnabled(context)) {
        Log_OC.d(TAG, "Instant picture upload disabled, ignoring new picture");
        return;
    }

    Account account = AccountUtils.getCurrentOwnCloudAccount(context);
    if (account == null) {
        Log_OC.w(TAG, "No account found for instant upload, aborting");
        return;
    }

    String[] CONTENT_PROJECTION = { Images.Media.DATA, Images.Media.DISPLAY_NAME, Images.Media.MIME_TYPE,
            Images.Media.SIZE };

    int permissionCheck = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE);

    if (android.content.pm.PackageManager.PERMISSION_GRANTED != permissionCheck) {
        Log_OC.w(TAG, "Read external storage permission isn't granted, aborting");
        return;
    }

    c = context.getContentResolver().query(intent.getData(), CONTENT_PROJECTION, null, null, null);
    if (!c.moveToFirst()) {
        Log_OC.e(TAG, "Couldn't resolve given uri: " + intent.getDataString());
        return;
    }
    file_path = c.getString(c.getColumnIndex(Images.Media.DATA));
    file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
    mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE));
    c.close();

    Log_OC.d(TAG, file_path + "");

    // save always temporally the picture to upload
    DbHandler db = new DbHandler(context);
    db.putFileForLater(file_path, account.name, null);
    db.close();

    if (!isOnline(context) || (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
        return;
    }

    Intent i = new Intent(context, FileUploader.class);
    i.putExtra(FileUploader.KEY_ACCOUNT, account);
    i.putExtra(FileUploader.KEY_LOCAL_FILE, file_path);
    i.putExtra(FileUploader.KEY_REMOTE_FILE, FileStorageUtils.getInstantUploadFilePath(context, file_name));
    i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
    i.putExtra(FileUploader.KEY_MIME_TYPE, mime_type);
    i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true);

    // instant upload behaviour
    i = addInstantUploadBehaviour(i, context);

    context.startService(i);
}

From source file:com.embeddedlog.LightUpDroid.timer.TimerReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    if (Timers.LOGGING) {
        Log.v(TAG, "Received intent " + intent.toString());
    }//from ww  w. ja  v  a 2 s  . c  o  m
    String actionType = intent.getAction();
    // This action does not need the timers data
    if (Timers.NOTIF_IN_USE_CANCEL.equals(actionType)) {
        cancelInUseNotification(context);
        return;
    }

    // Get the updated timers data.
    if (mTimers == null) {
        mTimers = new ArrayList<TimerObj>();
    }
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    TimerObj.getTimersFromSharedPrefs(prefs, mTimers);

    // These actions do not provide a timer ID, but do use the timers data
    if (Timers.NOTIF_IN_USE_SHOW.equals(actionType)) {
        showInUseNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_SHOW.equals(actionType)) {
        showTimesUpNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_CANCEL.equals(actionType)) {
        cancelTimesUpNotification(context);
        return;
    }

    // Remaining actions provide a timer Id
    if (!intent.hasExtra(Timers.TIMER_INTENT_EXTRA)) {
        // No data to work with, do nothing
        Log.e(TAG, "got intent without Timer data");
        return;
    }

    // Get the timer out of the Intent
    int timerId = intent.getIntExtra(Timers.TIMER_INTENT_EXTRA, -1);
    if (timerId == -1) {
        Log.d(TAG, "OnReceive:intent without Timer data for " + actionType);
    }

    TimerObj t = Timers.findTimer(mTimers, timerId);

    if (Timers.TIMES_UP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(TAG, " timer not found in list - do nothing");
            return;
        }

        t.mState = TimerObj.STATE_TIMESUP;
        t.writeToSharedPref(prefs);
        // Play ringtone by using TimerRingService service with a default alarm.
        Log.d(TAG, "playing ringtone");
        Intent si = new Intent();
        si.setClass(context, TimerRingService.class);
        context.startService(si);

        // Update the in-use notification
        if (getNextRunningTimer(mTimers, false, Utils.getTimeNow()) == null) {
            // Found no running timers.
            cancelInUseNotification(context);
        } else {
            showInUseNotification(context);
        }

        // Start the TimerAlertFullScreen activity.
        Intent timersAlert = new Intent(context, TimerAlertFullScreen.class);
        timersAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
        context.startActivity(timersAlert);
    } else if (Timers.TIMER_RESET.equals(actionType) || Timers.DELETE_TIMER.equals(actionType)
            || Timers.TIMER_DONE.equals(actionType)) {
        // Stop Ringtone if all timers are not in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_STOP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(TAG, "timer to stop not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(TAG, "action to stop but timer not in times-up state - do nothing");
            return;
        }

        // Update timer state
        t.mState = t.getDeleteAfterUse() ? TimerObj.STATE_DELETED : TimerObj.STATE_DONE;
        t.mTimeLeft = t.mOriginalLength - (Utils.getTimeNow() - t.mStartTime);
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // Done with timer - delete from data base
        if (t.getDeleteAfterUse()) {
            t.deleteFromSharedPref(prefs);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_PLUS_ONE.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(TAG, "timer to +1m not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(TAG, "action to +1m but timer not in times up state - do nothing");
            return;
        }

        // Restarting the timer with 1 minute left.
        t.mState = TimerObj.STATE_RUNNING;
        t.mStartTime = Utils.getTimeNow();
        t.mTimeLeft = t.mOriginalLength = TimerObj.MINUTE_IN_MILLIS;
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // If the app is not open, refresh the in-use notification
        if (!prefs.getBoolean(Timers.NOTIF_APP_OPEN, false)) {
            showInUseNotification(context);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.TIMER_UPDATE.equals(actionType)) {
        // Refresh buzzing notification
        if (t.mState == TimerObj.STATE_TIMESUP) {
            // Must cancel the previous notification to get all updates displayed correctly
            cancelTimesUpNotification(context, t);
            showTimesUpNotification(context, t);
        }
    }
    // Update the next "Times up" alarm
    updateNextTimesup(context);
}

From source file:se.oort.clockify.timer.TimerReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    if (Timers.LOGGING) {
        Log.v(LOG_TAG, "Received intent " + intent.toString());
    }/*from  w  w w .j  av  a  2s.  co m*/
    String actionType = intent.getAction();
    // This action does not need the timers data
    if (Timers.NOTIF_IN_USE_CANCEL.equals(actionType)) {
        cancelInUseNotification(context);
        return;
    }

    // Get the updated timers data.
    if (mTimers == null) {
        mTimers = new ArrayList<TimerObj>();
    }
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    TimerObj.getTimersFromSharedPrefs(prefs, mTimers);

    // These actions do not provide a timer ID, but do use the timers data
    if (Timers.NOTIF_IN_USE_SHOW.equals(actionType)) {
        showInUseNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_SHOW.equals(actionType)) {
        showTimesUpNotification(context);
        return;
    } else if (Timers.NOTIF_TIMES_UP_CANCEL.equals(actionType)) {
        cancelTimesUpNotification(context);
        return;
    }

    // Remaining actions provide a timer Id
    if (!intent.hasExtra(Timers.TIMER_INTENT_EXTRA)) {
        // No data to work with, do nothing
        Log.e(LOG_TAG, "got intent without Timer data");
        return;
    }

    // Get the timer out of the Intent
    int timerId = intent.getIntExtra(Timers.TIMER_INTENT_EXTRA, -1);
    if (timerId == -1) {
        Log.d(LOG_TAG, "OnReceive:intent without Timer data for " + actionType);
    }

    TimerObj t = Timers.findTimer(mTimers, timerId);

    if (Timers.TIMES_UP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(LOG_TAG, " timer not found in list - do nothing");
            return;
        }

        t.mState = TimerObj.STATE_TIMESUP;
        t.writeToSharedPref(prefs);
        // Play ringtone by using TimerRingService service with a default alarm.
        Log.d(LOG_TAG, "playing ringtone");
        Intent si = new Intent();
        si.setClass(context, TimerRingService.class);
        context.startService(si);

        // Update the in-use notification
        if (getNextRunningTimer(mTimers, false, Utils.getTimeNow()) == null) {
            // Found no running timers.
            cancelInUseNotification(context);
        } else {
            showInUseNotification(context);
        }

        // Start the TimerAlertFullScreen activity.
        Intent timersAlert = new Intent(context, TimerAlertFullScreen.class);
        timersAlert.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
        context.startActivity(timersAlert);
    } else if (Timers.TIMER_RESET.equals(actionType) || Timers.DELETE_TIMER.equals(actionType)
            || Timers.TIMER_DONE.equals(actionType)) {
        // Stop Ringtone if all timers are not in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_STOP.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(LOG_TAG, "timer to stop not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(LOG_TAG, "action to stop but timer not in times-up state - do nothing");
            return;
        }

        // Update timer state
        t.mState = t.getDeleteAfterUse() ? TimerObj.STATE_DELETED : TimerObj.STATE_DONE;
        t.mTimeLeft = t.mOriginalLength - (Utils.getTimeNow() - t.mStartTime);
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // Done with timer - delete from data base
        if (t.getDeleteAfterUse()) {
            t.deleteFromSharedPref(prefs);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.NOTIF_TIMES_UP_PLUS_ONE.equals(actionType)) {
        // Find the timer (if it doesn't exists, it was probably deleted).
        if (t == null) {
            Log.d(LOG_TAG, "timer to +1m not found in list - do nothing");
            return;
        } else if (t.mState != TimerObj.STATE_TIMESUP) {
            Log.d(LOG_TAG, "action to +1m but timer not in times up state - do nothing");
            return;
        }

        // Restarting the timer with 1 minute left.
        t.mState = TimerObj.STATE_RUNNING;
        t.mStartTime = Utils.getTimeNow();
        t.mTimeLeft = t.mOriginalLength = TimerObj.MINUTE_IN_MILLIS;
        t.writeToSharedPref(prefs);

        // Flag to tell DeskClock to re-sync with the database
        prefs.edit().putBoolean(Timers.FROM_NOTIFICATION, true).apply();

        cancelTimesUpNotification(context, t);

        // If the app is not open, refresh the in-use notification
        if (!prefs.getBoolean(Timers.NOTIF_APP_OPEN, false)) {
            showInUseNotification(context);
        }

        // Stop Ringtone if no timers are in times-up status
        stopRingtoneIfNoTimesup(context);
    } else if (Timers.TIMER_UPDATE.equals(actionType)) {
        // Refresh buzzing notification
        if (t.mState == TimerObj.STATE_TIMESUP) {
            // Must cancel the previous notification to get all updates displayed correctly
            cancelTimesUpNotification(context, t);
            showTimesUpNotification(context, t);
        }
    }
    // Update the next "Times up" alarm
    updateNextTimesup(context);
}

From source file:org.kontalk.service.msgcenter.MessageCenterService.java

public static void leaveGroup(final Context context, String groupJid, String[] to, boolean encrypt, long msgId,
        String packetId) {//  w ww .  j  ava  2s.  c  o m
    Intent i = new Intent(context, MessageCenterService.class);
    i.setAction(MessageCenterService.ACTION_MESSAGE);
    i.putExtra("org.kontalk.message.msgId", msgId);
    i.putExtra("org.kontalk.message.packetId", packetId);
    i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE);
    i.putExtra("org.kontalk.message.group.jid", groupJid);
    i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_PART);
    i.putExtra("org.kontalk.message.to", to);
    i.putExtra("org.kontalk.message.encrypt", encrypt);
    i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
    context.startService(i);
}

From source file:nl.hnogames.domoticz.Utils.NotificationUtil.java

public static void sendSimpleNotification(String title, String text, final Context context) {
    if (UsefulBits.isEmpty(title) || UsefulBits.isEmpty(text) || context == null)
        return;//from ww  w . j av  a  2s.c  om
    if (prefUtil == null)
        prefUtil = new SharedPrefUtil(context);
    prefUtil.addUniqueReceivedNotification(text);
    prefUtil.addLoggedNotification(new SimpleDateFormat("yyyy-MM-dd hh:mm ").format(new Date()) + text);

    List<String> suppressedNot = prefUtil.getSuppressedNotifications();
    List<String> alarmNot = prefUtil.getAlarmNotifications();
    try {
        if (prefUtil.isNotificationsEnabled() && suppressedNot != null && !suppressedNot.contains(text)) {
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.domoticz_white)
                    .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
                    .setContentTitle(alarmNot != null && alarmNot.contains(text)
                            ? context.getString(R.string.alarm) + ": " + title
                            : title)
                    .setContentText(alarmNot != null && alarmNot.contains(text)
                            ? context.getString(R.string.alarm) + ": " + text
                            : text)
                    .setGroupSummary(true).setGroup(GROUP_KEY_NOTIFICATIONS).setAutoCancel(true);

            if (!prefUtil.OverWriteNotifications())
                NOTIFICATION_ID = text.hashCode();
            if (prefUtil.getNotificationVibrate())
                builder.setDefaults(NotificationCompat.DEFAULT_VIBRATE);
            if (!UsefulBits.isEmpty(prefUtil.getNotificationSound()))
                builder.setSound(Uri.parse(prefUtil.getNotificationSound()));

            Intent targetIntent = new Intent(context, MainActivity.class);
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, targetIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            builder.setContentIntent(contentIntent);

            if (prefUtil.isNotificationsEnabled() && alarmNot != null && alarmNot.contains(text)) {
                Intent stopAlarmIntent = new Intent(context, StopAlarmButtonListener.class);
                PendingIntent pendingAlarmIntent = PendingIntent.getBroadcast(context, 78578, stopAlarmIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                builder.addAction(android.R.drawable.ic_delete, "Stop", pendingAlarmIntent);
            }

            if (prefUtil.showAutoNotifications()) {
                builder.extend(new NotificationCompat.CarExtender()
                        .setUnreadConversation(getUnreadConversation(context, text)));
            }

            NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, builder.build());
            if (prefUtil.isNotificationsEnabled() && alarmNot != null && alarmNot.contains(text)) {
                Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
                if (alert == null) {
                    alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                    if (alert == null)
                        alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
                }
                if (alert != null) {
                    Intent ringtoneServiceStartIntent = new Intent(context, RingtonePlayingService.class);
                    ringtoneServiceStartIntent.putExtra("ringtone-uri", alert.toString());
                    context.startService(ringtoneServiceStartIntent);

                    if (prefUtil.getAlarmTimer() > 0) {
                        Thread.sleep(prefUtil.getAlarmTimer() * 1000);
                        Intent stopIntent = new Intent(context, RingtonePlayingService.class);
                        context.stopService(stopIntent);
                    }
                }
            }
        }
    } catch (Exception ex) {
        Log.i("NOTIFY", ex.getMessage());
    }
}

From source file:org.kontalk.service.msgcenter.MessageCenterService.java

public static void sendGroupTextMessage(final Context context, String groupJid, String groupSubject,
        String[] to, String text, boolean encrypt, long msgId, String packetId) {
    Intent i = new Intent(context, MessageCenterService.class);
    i.setAction(MessageCenterService.ACTION_MESSAGE);
    i.putExtra("org.kontalk.message.msgId", msgId);
    i.putExtra("org.kontalk.message.packetId", packetId);
    i.putExtra("org.kontalk.message.mime", TextComponent.MIME_TYPE);
    i.putExtra("org.kontalk.message.group.jid", groupJid);
    i.putExtra("org.kontalk.message.group.subject", groupSubject);
    i.putExtra("org.kontalk.message.to", to);
    i.putExtra("org.kontalk.message.body", text);
    i.putExtra("org.kontalk.message.encrypt", encrypt);
    i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
    context.startService(i);
}

From source file:org.kontalk.service.msgcenter.MessageCenterService.java

public static void createGroup(final Context context, String groupJid, String groupSubject, String[] to,
        boolean encrypt, long msgId, String packetId) {
    Intent i = new Intent(context, MessageCenterService.class);
    i.setAction(MessageCenterService.ACTION_MESSAGE);
    i.putExtra("org.kontalk.message.msgId", msgId);
    i.putExtra("org.kontalk.message.packetId", packetId);
    i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE);
    i.putExtra("org.kontalk.message.group.jid", groupJid);
    i.putExtra("org.kontalk.message.group.subject", groupSubject);
    i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_CREATE);
    i.putExtra("org.kontalk.message.to", to);
    i.putExtra("org.kontalk.message.encrypt", encrypt);
    i.putExtra("org.kontalk.message.chatState", ChatState.active.name());
    context.startService(i);
}