List of usage examples for android.app Activity startService
@Override
public ComponentName startService(Intent service)
From source file:com.qasp.diego.arsp.indice_localFrag.java
public static void verifyGPSpermission(Activity activity) { int GPSpermission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION); if (GPSpermission != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, GPS_ACESS);//ww w . jav a2s . c om } else { Intent intent = new Intent(activity, LocalizacaoGPSService.class); activity.startService(intent); } }
From source file:com.silentcircle.contacts.interactions.GroupCreationDialogFragment.java
@Override protected void onCompleted(String groupLabel) { // Indicate to the listener that a new group will be created. // If the device is rotated, mListener will become null, so that the // popup from GroupMembershipView will not be shown. if (mListener != null) { mListener.onGroupCreated();/*from w w w .ja v a2s . co m*/ } Activity activity = getActivity(); activity.startService(ScContactSaveService.createNewGroupIntent(activity, groupLabel, null /* no new members to add */, activity.getClass(), Intent.ACTION_EDIT)); }
From source file:com.ui.UiActivity.java
public void startServiceActivity(Activity activity, Intent intent) { activity.startService(intent); }
From source file:com.github.olga_yakovleva.rhvoice.android.DataInstallationFragment.java
@Override public void onResume() { super.onResume(); Activity activity = getActivity(); LocalBroadcastManager.getInstance(activity).registerReceiver(receiver, new IntentFilter(DataService.ACTION_DATA_STATE)); activity.startService(new Intent(activity, DataService.class)); }
From source file:me.tassoevan.cordova.BackgroundPlugin.java
private void startService() { Activity context = cordova.getActivity(); Intent intent = new Intent(context, ForegroundService.class); if (isDisabled || isBind) { return;//from w w w . j a va 2 s . com } context.bindService(intent, connection, Context.BIND_AUTO_CREATE); context.startService(intent); isBind = true; }
From source file:com.alchemiasoft.book.fragment.BookDetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (!data.moveToNext()) { return;/* w w w . ja va2 s . c om*/ } final Book book = Book.oneFrom(data); mTitleTextView.setText(book.getTitle()); mAuthorTextView.setText(book.getAuthor()); mSourceTextView.setText(getString(R.string.source, book.getSource())); mDescriptionTextView.setText(book.getDescrition()); mNotesTextView.setText(book.getNotes()); mPagesTextView.setText( getString(R.string.pages, (book.getPages() >= 0 ? book.getPages() : getString(R.string.unknown)))); mActionButton.setText(book.isOwned() ? R.string.action_sell : R.string.action_buy); mActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mActionButton.setEnabled(false); final Activity activity = getActivity(); final BookActionService.IntentBuilder builder = book.isOwned() ? BookActionService.IntentBuilder.sell(activity, book) : BookActionService.IntentBuilder.buy(activity, book); activity.startService(builder.build()); } }); mActionButton.setEnabled(true); }
From source file:com.anand.music.PlaylistFragment.java
/** * Launches the {@link com.jarekandshawnmusic.m.MediaPlayerService} * to play the requested playlist, or re-initializes an existing * {@link com.jarekandshawnmusic.m.MediaPlayerService} with a new playlist. * @param playlist the list of songs to play *//*w w w. j a v a 2s . com*/ public void setPlaylist(ArrayList<Integer> playlist) { if (mBound) { mMediaPlayerService.setPlaylist(playlist); mMediaPlayerService.play(); } else { Activity containerActivity = getActivity(); Intent playlistIntent = new Intent(containerActivity, MediaPlayerService.class); playlistIntent.putIntegerArrayListExtra("playlist", playlist); containerActivity.startService(playlistIntent); // We start this service and then bind to it, so we can control the playback // and get progress updates. containerActivity.bindService(playlistIntent, mConnection, Context.BIND_AUTO_CREATE); } }
From source file:org.jared.synodroid.ds.action.AddTaskAction.java
public void execute(ResponseHandler handlerP, SynoServer serverP) throws Exception { if (use_safe && serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) { //new TorrentDownloadAndAdd((Fragment)handlerP).execute(uri.toString()); Activity a = ((Fragment) handlerP).getActivity(); Intent msgIntent = new Intent(a, DownloadIntentService.class); msgIntent.putExtra(DownloadIntentService.URL, uri.toString()); msgIntent.putExtra(DownloadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG); a.startService(msgIntent); } else {/*from w w w .j a va2 s .c o m*/ if (task.outside_url) { // Start task using url instead of reading file serverP.getDSMHandlerFactory().getDSHandler().uploadUrl(uri, null, null); } else { //serverP.getDSMHandlerFactory().getDSHandler().upload((Fragment) handlerP, uri); Activity a = ((Fragment) handlerP).getActivity(); Intent msgIntent = new Intent(a, UploadIntentService.class); msgIntent.putExtra(UploadIntentService.URL, uri.toString()); if (serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) { msgIntent.putExtra(UploadIntentService.DIRECTORY, ""); } else { msgIntent.putExtra(UploadIntentService.DIRECTORY, serverP.getDSMHandlerFactory().getDSHandler().getSharedDirectory(false)); } msgIntent.putExtra(UploadIntentService.COOKIES, serverP.getCookies()); msgIntent.putExtra(UploadIntentService.DSM_VERSION, serverP.getDsmVersion().getTitle()); msgIntent.putExtra(UploadIntentService.PATH, serverP.getUrl()); msgIntent.putExtra(UploadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG); a.startService(msgIntent); } } }
From source file:org.jared.synodroid.ds.action.AddPwTaskAction.java
public void execute(ResponseHandler handlerP, SynoServer serverP) throws Exception { if (use_safe && serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) { //new TorrentDownloadAndAdd((Fragment)handlerP).execute(uri.toString()); Activity a = ((Fragment) handlerP).getActivity(); Intent msgIntent = new Intent(a, DownloadIntentService.class); msgIntent.putExtra(DownloadIntentService.URL, uri.toString()); msgIntent.putExtra(DownloadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG); a.startService(msgIntent); } else {//from ww w.j a v a 2s . c o m if (task.outside_url) { // Start task using url instead of reading file serverP.getDSMHandlerFactory().getDSHandler().uploadUrl(uri, uname, pass); } else { Activity a = ((Fragment) handlerP).getActivity(); Intent msgIntent = new Intent(a, UploadIntentService.class); msgIntent.putExtra(UploadIntentService.URL, uri.toString()); if (serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) { msgIntent.putExtra(UploadIntentService.DIRECTORY, ""); } else { msgIntent.putExtra(UploadIntentService.DIRECTORY, serverP.getDSMHandlerFactory().getDSHandler().getSharedDirectory(false)); } msgIntent.putExtra(UploadIntentService.COOKIES, serverP.getCookies()); msgIntent.putExtra(UploadIntentService.DSM_VERSION, serverP.getDsmVersion().getTitle()); msgIntent.putExtra(UploadIntentService.PATH, serverP.getUrl()); msgIntent.putExtra(UploadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG); a.startService(msgIntent); } } }
From source file:com.anand.music.PlaylistFragment.java
@Override public void onStart() { super.onStart(); Activity containerActivity = getActivity(); Intent playlistIntent = new Intent(containerActivity, MediaPlayerService.class); if (MediaPlayerService.mHasLaunched) { if (!mBound) { containerActivity.bindService(playlistIntent, mConnection, Context.BIND_AUTO_CREATE); }/*from ww w .java2s . c o m*/ } else { containerActivity.startService(playlistIntent); containerActivity.bindService(playlistIntent, mConnection, Context.BIND_AUTO_CREATE); } }