List of usage examples for android.content Context startService
@Nullable public abstract ComponentName startService(Intent service);
From source file:com.sonycsl.fechonet.FWidgetProvider.java
@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { //Toast.makeText(context, "Widget Updated", Toast.LENGTH_LONG).show(); Intent in = new Intent(context, WidgetService.class); context.startService(in); }
From source file:com.drextended.actionhandler.action.IntentAction.java
/** * Request that a given application service be started. * Override this method if you need specific behaviour. * * @param context The Context, which generally get from view by {@link View#getContext()} * @param intent The intent to start service, provided by {@link #getIntent(View, Context, String, Object)} *///from ww w.ja v a 2s . com protected void startService(Context context, Intent intent) throws SecurityException { context.startService(intent); }
From source file:jp.co.conit.sss.sn.ex2.service.GCMIntentService.java
@Override protected void onRegistered(Context context, String registrationId) { Intent intentService = new Intent(); intentService.setClass(context, RegistService.class); intentService.putExtra("registration_id", registrationId); context.startService(intentService); }
From source file:com.juick.android.XMPPMessageReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { context.startService(new Intent(context, XMPPService.class)); }// w ww.j av a 2 s .co m if (intent.getAction().equals(XMPPService.ACTION_MESSAGE_RECEIVED)) { int nMessages = intent.getIntExtra("messagesCount", 0); boolean sound = intent.getBooleanExtra("sound", true); XMPPService.IncomingMessage messag = (XMPPService.IncomingMessage) intent .getSerializableExtra("message"); if (nMessages == 0) return; ArrayList<MessageReceiverListener> allListeners = (ArrayList<MessageReceiverListener>) listeners .clone(); boolean handled = false; for (MessageReceiverListener listener : allListeners) { handled |= listener.onMessageReceived(messag); } if (!handled) { updateInfo(context, nMessages, !sound); } } if (intent.getAction().equals(XMPPService.ACTION_LAUNCH_MESSAGELIST)) { Intent nintent = new Intent(context, XMPPIncomingMessagesActivity.class); nintent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); nintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(nintent); } }
From source file:com.chen.mail.utils.NotificationActionUtils.java
/** * Broadcasts an {@link Intent} to inform the app to resend its notifications. *///from ww w . j a v a 2 s . co m public static void resendNotifications(final Context context, final Account account, final Folder folder) { LogUtils.i(LOG_TAG, "resendNotifications account: %s, folder: %s", LogUtils.sanitizeName(LOG_TAG, account.name), LogUtils.sanitizeName(LOG_TAG, folder.name)); final Intent intent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS); intent.setPackage(context.getPackageName()); // Make sure we only deliver this to ourself intent.putExtra(Utils.EXTRA_ACCOUNT_URI, account.uri); intent.putExtra(Utils.EXTRA_FOLDER_URI, folder.folderUri.fullUri); context.startService(intent); }
From source file:com.jesusla.google.BillingReceiver.java
/** * This is called when Android Market sends a "notify" message indicating that transaction * information is available. The request includes a nonce (random number used once) that * we generate and Android Market signs and sends back to us with the purchase state and * other transaction details. This BroadcastReceiver cannot bind to the * MarketBillingService directly so it starts the {@link BillingService}, which does the * actual work of sending the message.// ww w .j av a 2 s.c o m * * @param context the context * @param notifyId the notification ID */ private void notify(Context context, String notifyId) { Intent intent = new Intent(Consts.ACTION_GET_PURCHASE_INFORMATION); intent.setClass(context, BillingService.class); intent.putExtra(Consts.NOTIFICATION_ID, notifyId); context.startService(intent); }
From source file:com.horizondigital.delta.UpdateService.java
private static void start(Context context, String action) { Intent i = new Intent(context, UpdateService.class); i.setAction(action);/*from w w w. j av a 2 s . c o m*/ context.startService(i); }
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) {/*w w w. j a v a 2s . com*/ 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); } }
From source file:org.linuxac.bilal.BilalAlarm.java
@Override public void onReceive(Context context, Intent intent) { String message = intent.getStringExtra(BilalActivity.NOTIFY_MESSAGE); Log.d(BilalActivity.TAG, "Alarm is ON: " + message); // Play athan Intent audioIntent = new Intent(context, AthanAudio.class); context.startService(audioIntent); // Build intent for notification content int notificationId = 0; int eventId = 0; Intent nextPrayerIntent = new Intent(context, BilalActivity.class); nextPrayerIntent.putExtra(EXTRA_EVENT_ID, eventId); PendingIntent nextPrayerPendingIntent = PendingIntent.getActivity(context, 0, nextPrayerIntent, 0); // Use another intent to stop athan from notification button PendingIntent cancelAthanPendingIntent = CancelAthanActivity.getCancelAthanIntent(notificationId, context); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(BilalActivity.TAG).setContentText(message) .setContentIntent(nextPrayerPendingIntent).setCategory(NotificationCompat.CATEGORY_ALARM) .setAutoCancel(true).setDeleteIntent(cancelAthanPendingIntent) .addAction(R.drawable.ic_clear, "? ", cancelAthanPendingIntent); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); // Build the notification and issues it with notification manager. notificationManager.notify(notificationId, notificationBuilder.build()); // ask Activity to update display to next prayer. TODO: delay highlighting of next prayer Intent updateIntent = new Intent(BilalActivity.UPDATE_MESSAGE); context.sendBroadcast(updateIntent); }
From source file:com.tonikorin.cordova.plugin.LocationProvider.LocationProviderPlugin.java
private void startService(String notification) { Log.d(TAG, "startService"); Context context = cordova.getActivity().getApplicationContext(); Intent serviceIntent = new Intent(); serviceIntent.putExtra("data", notification); serviceIntent.setClassName(context, "com.tonikorin.cordova.plugin.LocationProvider.LocationService"); context.startService(serviceIntent); }