@Override public void onClick(View v) { Intent intent = new Intent(DownService.CANCLE_ALL_DOWNTASK); intent.setPackage(IConstants.PACKAGE); mContext.startService(intent); } });
@Override public void onClick(View v) { Intent intent = new Intent(DownService.START_ALL_DOWNTASK); intent.setPackage(IConstants.PACKAGE); mContext.startService(intent); } });
@Override public void onClick(View v) { Intent intent = new Intent(DownService.PAUSE_ALLTASK); intent.setPackage(IConstants.PACKAGE); mContext.startService(intent); } });
@Override public void onClick(View v) { if (isPreparing1) { L.D(d, TAG, "isprepaing"); Intent intent = new Intent(DownService.PAUSE_TASK); intent.setPackage(IConstants.PACKAGE); intent.putExtra("downloadid", task.getDownloadId()); mContext.startService(intent); } else { L.D(d, TAG, "not isprepaing"); Intent intent = new Intent(DownService.RESUME_START_DOWNTASK); intent.setPackage(IConstants.PACKAGE); intent.putExtra("downloadid", task.getDownloadId()); mContext.startService(intent); } } });
Intent intent = new Intent(activity, DownloadService.class); intent.setAction(DownloadService.ACTION_START_ALL); activity.startService(intent); return true;
intent.setAction(DownloadService.ACTION_START); intent.putExtra(DownloadService.KEY_GALLERY_INFO, list.get(index)); activity.startService(intent); } else if (stop == v) { if (null != mDownloadManager) {
@Override public boolean onPreferenceChange(Preference pref, Object newValue) { Boolean value=(Boolean)newValue; Intent i=new Intent(getActivity(), LocationPollerService.class); if (value) { if (Build.VERSION.SDK_INT>Build.VERSION_CODES.N_MR1) { getActivity().startForegroundService(i); } else { getActivity().startService(i); } } else { getActivity().stopService(i); } getActivity().finish(); return(true); }
@Test public void shouldHaveStoppedServiceByStartedComponent() { ShadowApplication shadowApplication = shadowOf(context); Activity activity = Robolectric.setupActivity(Activity.class); ComponentName componentName = new ComponentName("package.test", "package.test.TestClass"); Intent startServiceIntent = new Intent().setComponent(componentName); ComponentName startedComponent = activity.startService(startServiceIntent); assertThat(startedComponent.getPackageName()).isEqualTo("package.test"); assertThat(startedComponent.getClassName()).isEqualTo("package.test.TestClass"); Intent stopServiceIntent = new Intent().setComponent(startedComponent); stopServiceIntent.putExtra("someExtra", "someValue"); boolean wasRunning = activity.stopService(stopServiceIntent); assertTrue(wasRunning); final Intent nextStoppedService = shadowApplication.getNextStoppedService(); assertThat(nextStoppedService.filterEquals(startServiceIntent)).isTrue(); assertThat(nextStoppedService.getStringExtra("someExtra")).isEqualTo("someValue"); }
intent.setAction(DownloadService.ACTION_START_RANGE); intent.putExtra(DownloadService.KEY_GID_LIST, gidList); activity.startService(intent);
@Test public void shouldHaveStoppedServiceIntentAndIndicateServiceWasRunning() { ShadowApplication shadowApplication = shadowOf(context); Activity activity = Robolectric.setupActivity(Activity.class); Intent intent = getSomeActionIntent("some.action"); activity.startService(intent); boolean wasRunning = activity.stopService(intent); assertTrue(wasRunning); assertThat(shadowApplication.getNextStoppedService()).isEqualTo(intent); }
.setMessage(R.string.st_reset_database_question) .setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { getActivity().startService(intent); Toast.makeText(getActivity(), R.string.st_reset_database_done, Toast.LENGTH_LONG).show(); }) .setMessage(R.string.st_reset_deltas_question) .setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { getActivity().startService(intent); Toast.makeText(getActivity(), R.string.st_reset_deltas_done, Toast.LENGTH_LONG).show(); })
public static void startSync(Activity activity, boolean initialSync) { Intent syncIntent = new Intent(ACTION_SYNC, null, activity, SyncService.class); syncIntent.putExtra(EXTRA_TYPE, SyncType.FULL_SYNC.action); syncIntent.putExtra(EXTRA_INITIAL_SYNC, initialSync); activity.startService(syncIntent); }
@Override public void onClick(View view) { // stop sleep timer service using intent Intent intent = new Intent(mActivity, SleepTimerService.class); intent.setAction(ACTION_TIMER_STOP); mActivity.startService(intent); mSleepTimerRunning = false; // notify user Toast.makeText(mActivity, mActivity.getString(R.string.toastmessage_timer_cancelled), Toast.LENGTH_SHORT).show(); LogHelper.v(LOG_TAG, "Sleep timer cancelled."); } });
@Override public void onDeviceSelected(final BluetoothDevice device, final String name) { final Activity activity = getActivity(); final Intent service = new Intent(activity, UpdateService.class); service.putExtra(UpdateService.EXTRA_DATA, device); activity.startService(service); mBinded = true; activity.bindService(service, mServiceConnection, 0); }
@Override public ComponentName startService(Intent mIntent) { PluginDebugLog.runtimeLog(TAG, "InstrActivityProxy1 startService...."); if (mLoadedApk != null) { ComponentFinder.switchToServiceProxy(mLoadedApk, mIntent); } return super.startService(mIntent); }
@Override public boolean onPreferenceChange(Preference preference, Object o) { boolean isEnabled = (boolean) o; AppPreference.setNotificationEnabled(getActivity(), isEnabled); Intent intentToStartUpdate = new Intent("org.thosp.yourlocalweather.action.RESTART_NOTIFICATION_ALARM_SERVICE"); intentToStartUpdate.setPackage("org.thosp.yourlocalweather"); getActivity().startService(intentToStartUpdate); return true; } };
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { // changes made to these preference will be reflected instantly in the trigger; for others, restart the service if (!(key.equals("triggerOffset") || key.equals("triggerWidth") || key.equals("triggerHeight"))) { Intent intent = new Intent(getActivity(), PreferenceTrigger.class); getActivity().stopService(intent); getActivity().startService(intent); } }
@Test public void testCheckAndStartService_for_always_strategy() throws Exception { manager.checkAndStartService(activity, CheckingStrategy.ALWAYS); verify(activity, atLeastOnce()).startService(new Intent(activity, VersionCheckerService.class)); }
@Test public void testCheckAndStartService_for_one_per_day_strategy() throws Exception { when(sharedDataProvider.provideLastCheckTime()).thenReturn(new Date().getTime() - TimeUnit.HOURS.toMillis(2)); when(formatUtils.formatTodayDate()).thenReturn(new Date()); manager.checkAndStartService(activity, CheckingStrategy.ONE_PER_DAY); verify(activity, atLeastOnce()).startService(new Intent(activity, VersionCheckerService.class)); }
@Test public void testCheckAndStartService_for_one_per_version_per_day_strategy() throws Exception { when(sharedDataProvider.provideLastCheckTime()).thenReturn(new Date().getTime() - TimeUnit.HOURS.toMillis(2)); when(formatUtils.formatTodayDate()).thenReturn(new Date()); manager.checkAndStartService(activity, CheckingStrategy.ONE_PER_VERSION_PER_DAY); verify(activity, atLeastOnce()).startService(new Intent(activity, VersionCheckerService.class)); }