List of usage examples for android.content Context startService
@Nullable public abstract ComponentName startService(Intent service);
From source file:org.simlar.SimlarServiceCommunicator.java
private void startServiceAndRegister(final Context context, final Class<?> activity, boolean onlyRegister) { mActivity = activity;/* w w w .java 2 s . c om*/ final Intent intent = new Intent(context, SimlarService.class); if (!onlyRegister) { context.startService(intent); } context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); LocalBroadcastManager.getInstance(context).registerReceiver(mReceiver, new IntentFilter(SimlarServiceBroadcast.BROADCAST_NAME)); }
From source file:com.roamprocess1.roaming4world.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); System.out.println("GcmBroadcastReceiver :onReceive "); Intent i = new Intent(context, SipService.class); context.startService(i); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK);/*from w w w.j av a 2 s.com*/ }
From source file:com.google.android.apps.paco.NotificationCreator.java
private void notifySyncService(Context context) { context.startService(new Intent(context, SyncService.class)); }
From source file:com.android.tv.receiver.BootCompletedReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (DEBUG)//w w w . j a va 2s.com Log.d(TAG, "boot completed " + intent); // Start {@link NotificationService}. Intent notificationIntent = new Intent(context, NotificationService.class); notificationIntent.setAction(NotificationService.ACTION_SHOW_RECOMMENDATION); context.startService(notificationIntent); // Grant permission to already set up packages after the system has finished booting. SetupUtils.grantEpgPermissionToSetUpPackages(context); if (Features.UNHIDE.isEnabled(context)) { if (OnboardingUtils.isFirstBoot(context)) { // Enable the application if this is the first "unhide" feature is enabled just in // case when the app has been disabled before. PackageManager pm = context.getPackageManager(); ComponentName name = new ComponentName(context, TvActivity.class); if (pm.getComponentEnabledSetting(name) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0); } OnboardingUtils.setFirstBootCompleted(context); } } if (CommonFeatures.DVR.isEnabled(context) && BuildCompat.isAtLeastN()) { DvrRecordingService.startService(context); } }
From source file:com.PrivacyGuard.Application.Network.FakeVPN.MyVpnService.java
public void startVPN(Context context) { Intent intent = new Intent(context, MyVpnService.class); context.startService(intent); started = true;// w w w . ja v a 2 s .com }
From source file:com.jesusla.google.BillingReceiver.java
/** * This is called when Android Market sends information about a purchase state * change. The signedData parameter is a plaintext JSON string that is * signed by the server with the developer's private key. The signature * for the signed data is passed in the signature parameter. * @param context the context/* ww w .j av a 2s . c o m*/ * @param signedData the (unencrypted) JSON string * @param signature the signature for the signedData */ private void purchaseStateChanged(Context context, String signedData, String signature) { Intent intent = new Intent(Consts.ACTION_PURCHASE_STATE_CHANGED); intent.setClass(context, BillingService.class); intent.putExtra(Consts.INAPP_SIGNED_DATA, signedData); intent.putExtra(Consts.INAPP_SIGNATURE, signature); context.startService(intent); }
From source file:com.jesusla.google.BillingReceiver.java
/** * This is called when Android Market sends a server response code. The BillingService can * then report the status of the response if desired. * * @param context the context/* w w w . j ava 2 s . c o m*/ * @param requestId the request ID that corresponds to a previous request * @param responseCodeIndex the ResponseCode ordinal value for the request */ private void checkResponseCode(Context context, long requestId, int responseCodeIndex) { Intent intent = new Intent(Consts.ACTION_RESPONSE_CODE); intent.setClass(context, BillingService.class); intent.putExtra(Consts.INAPP_REQUEST_ID, requestId); intent.putExtra(Consts.INAPP_RESPONSE_CODE, responseCodeIndex); context.startService(intent); }
From source file:org.y20k.transistor.helpers.SleepTimerService.java
public void startActionStop(Context context) { LogHelper.v(LOG_TAG, "Stopping sleep timer."); // stop sleep timer service using intent Intent intent = new Intent(context, SleepTimerService.class); intent.setAction(TransistorKeys.ACTION_TIMER_STOP); context.startService(intent); }
From source file:org.ohmage.reminders.types.time.TimeTrigger.java
@Override public void startTrigger(Context context, int trigId, String trigDesc) { Intent i = new Intent(context, TimeTrigService.class); i.setAction(TimeTrigService.ACTION_SET_TRIGGER); i.putExtra(TimeTrigService.KEY_TRIG_ID, trigId); i.putExtra(TimeTrigService.KEY_TRIG_DESC, trigDesc); context.startService(i); }
From source file:com.example.olivi.maphap.widget.DetailWidgetProvider.java
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { //Start up DetailWidgetIntentService to query for regions data and see when it was last // updated. If the data is too old, the service will update it using MapHapService. Intent i = new Intent(context, DetailWidgetIntentService.class); context.startService(i); // Perform this loop procedure for each App Widget that belongs to this provider for (int appWidgetId : appWidgetIds) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_detail); // Create an Intent to launch MainActivity Intent intent = new Intent(context, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); views.setOnClickPendingIntent(R.id.widget_detail, pendingIntent); // Set up the collection if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { setRemoteAdapter(context, views); } else {// ww w . j a va2 s . c o m setRemoteAdapterV11(context, views); } Intent clickIntentTemplate = new Intent(context, DetailActivity.class); PendingIntent clickPendingIntentTemplate = TaskStackBuilder.create(context) .addNextIntentWithParentStack(clickIntentTemplate) .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); views.setPendingIntentTemplate(R.id.widget_list, clickPendingIntentTemplate); views.setEmptyView(R.id.widget_list, R.id.widget_empty); // Tell the AppWidgetManager to perform an update on the current app com.example // .olivi.maphap.widget appWidgetManager.updateAppWidget(appWidgetId, views); } }