List of usage examples for android.content Context BIND_AUTO_CREATE
int BIND_AUTO_CREATE
To view the source code for android.content Context BIND_AUTO_CREATE.
Click Source Link
From source file:com.royer.bangstopwatch.app.StopwatchFragment.java
@Override public void onStart() { super.onStart(); Log.d(TAG, "onStart()..."); if (_timekeeper.isrunning()) { /**/*from w ww . ja v a 2 s.c o m*/ * because in onStop() we stop the time task, so we need restart * the time task */ startTimerTask(); } if (state == this.STATE_RUNNING) { // it must bound the service Intent intent = new Intent(getActivity(), RecordService.class); getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } }
From source file:edu.asu.cse535.assignment3.MainActivity.java
public void classifyActivity(View v) { final Handler testHandler = new Handler() { @Override/*from ww w . ja va 2s . c o m*/ public void handleMessage(Message msg) { Log.w(this.getClass().getSimpleName(), "Message received and stopping service"); Bundle b = msg.getData(); ActivityData activityData = (ActivityData) b.getSerializable("ActivityData"); notifyCompletion(); stopService(testIntent); unbindService(testServiceConnection); AndroidLibsvmClassifier androidLibsvmClassifier = new AndroidLibsvmClassifier(); String activity = androidLibsvmClassifier.classify(activityData); toastActivity(activity); } }; testIntent = new Intent(MainActivity.this.getBaseContext(), AccIntentService.class); testIntent.putExtra("activity", Constants.CLASSIFY); testServiceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { AccIntentService testAaccIntentService = ((AccIntentService.LocalBinder) service).getInstance(); testAaccIntentService.setHandler(testHandler); Log.w(this.getClass().getSimpleName(), "Test activity is connected to service"); } @Override public void onServiceDisconnected(ComponentName name) { } }; startService(testIntent); bindService(testIntent, testServiceConnection, Context.BIND_AUTO_CREATE); }
From source file:net.networksaremadeofstring.rhybudd.RhybuddDream.java
void doBindService() { bindService(new Intent(this, ZenossPoller.class), mConnection, Context.BIND_AUTO_CREATE); mBound = true;//from w w w. java 2 s . c o m RhybuddDataSource datasource = new RhybuddDataSource(this); datasource.open(); listOfDevices = datasource.GetRhybuddDevices(); datasource.close(); }
From source file:com.wordpress.ebc81.rtl_ais_android.DeviceOpenActivity.java
/** * Starts the rtl ais binary//w ww.j ava 2 s.c o m */ public void startBinary(final String arguments, final int fd, final String uspfs_path) { try { Log.v("TEST", "startBinary"); //start the service this.args = arguments; this.fd = fd; this.uspfs_path = uspfs_path; final Intent intent = new Intent(this, BinaryRunnerService.class); startService(intent); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } catch (Exception e) { finishWithError(e); } }
From source file:com.project.richard.insightjournal.ui.timerscreen.TimerFragment.java
@Override public void onResume() { super.onResume(); EventBus.getDefault().register(this); Intent intent = new Intent(getActivity(), TimerService.class); getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); getActivity().startService(intent);/*from w w w.j a v a2 s . co m*/ mGoogleApiClient.connect(); }
From source file:com.mbientlab.metawear.app.CustomFragment.java
private void startService(Class<?> service, ServiceConnection serviceConnection, Bundle extras) { if (!UsbService.SERVICE_CONNECTED) { Intent startService = new Intent(getActivity(), service); if (extras != null && !extras.isEmpty()) { Set<String> keys = extras.keySet(); for (String key : keys) { String extra = extras.getString(key); startService.putExtra(key, extra); }// w ww. j av a2s . co m } getActivity().startService(startService); } Intent bindingIntent = new Intent(getActivity(), service); getActivity().bindService(bindingIntent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:hku.fyp14017.blencode.drone.DroneInitializer.java
@Override public void onDroneAvailabilityChanged(boolean isDroneOnNetwork) { // Here we know that the drone is on the network Log.d(TAG, "Drone availability = " + isDroneOnNetwork); if (isDroneOnNetwork) { Intent startService = new Intent(prestageStageActivity, DroneControlService.class); Object obj = prestageStageActivity.startService(startService); boolean isSuccessful = prestageStageActivity.bindService( new Intent(prestageStageActivity, DroneControlService.class), this.droneServiceConnection, Context.BIND_AUTO_CREATE); // TODO Drone: Condition has no effect, even drone is not connected a connection will be "established" if (obj == null || !isSuccessful) { prestageStageActivity.resourceFailed(); }/* w w w .j a va2 s. c o m*/ } else { showUncancelableErrorDialog(prestageStageActivity, prestageStageActivity.getString(hku.fyp14017.blencode.R.string.error_no_drone_connected_title), prestageStageActivity.getString(hku.fyp14017.blencode.R.string.error_no_drone_connected)); } }
From source file:com.davidmiguel.gobees.monitoring.MonitoringFragment.java
@Override public void bindMonitoringService() { Intent intent = new Intent(getActivity(), MonitoringService.class); getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:com.owncloud.android.ui.activity.FileActivity.java
/** * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of * the {@link FileActivity}.//from w w w . j a v a2s . c o m * * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user * is requested to create a new one. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); mFileOperationsHelper = new FileOperationsHelper(this); Account account = null; if (savedInstanceState != null) { mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE); mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION); mFileOperationsHelper .setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)); mTryShareAgain = savedInstanceState.getBoolean(KEY_TRY_SHARE_AGAIN); if (getSupportActionBar() != null) { getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE)); } } else { account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT); mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE); mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false); } AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager // or database setAccount(account, savedInstanceState != null); mOperationsServiceConnection = new OperationsServiceConnection(); bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE); mDownloadServiceConnection = newTransferenceServiceConnection(); if (mDownloadServiceConnection != null) { bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, Context.BIND_AUTO_CREATE); } mUploadServiceConnection = newTransferenceServiceConnection(); if (mUploadServiceConnection != null) { bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE); } }
From source file:eu.basicairdata.graziano.gpslogger.GPSApplication.java
private void StartAndBindGPSService() { GPSServiceIntent = new Intent(GPSApplication.this, GPSService.class); //Start the service startService(GPSServiceIntent);// w ww . jav a 2 s . c om //Bind to the service if (Build.VERSION.SDK_INT >= 14) bindService(GPSServiceIntent, GPSServiceConnection, Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT); else bindService(GPSServiceIntent, GPSServiceConnection, Context.BIND_AUTO_CREATE); Log.w("myApp", "[#] GPSApplication.java - StartAndBindGPSService"); }