Example usage for android.content Context BIND_AUTO_CREATE

List of usage examples for android.content Context BIND_AUTO_CREATE

Introduction

In this page you can find the example usage for android.content Context BIND_AUTO_CREATE.

Prototype

int BIND_AUTO_CREATE

To view the source code for android.content Context BIND_AUTO_CREATE.

Click Source Link

Document

Flag for #bindService : automatically create the service as long as the binding exists.

Usage

From source file:com.sdrtouch.rtlsdr.StreamActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (mAdView != null) { // Check if Adview is not null in case of fist time load.
        mAdView.resume();// w  w w  .  ja v  a2s . c  om
    }
    terminal.setText(Log.getFullLog());
    bindService(new Intent(this, BinaryRunnerService.class), mConnection, Context.BIND_AUTO_CREATE);
    Log.registerCallback(this);
}

From source file:com.example.sleepintrain.CheckDistance.java

public void bind() {
    try {//from w w  w .ja  va2 s  .c om
        gpsService.setVibrateSignalTrue();
    } catch (Exception e) {

    }
    if (mdes != null) {
        Toast.makeText(CheckDistance.this, "bind in checkDistance", Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(this, GpsReadingService.class);
        intent.putExtra(EXTRA_MESSAGE, message);
        intent.putExtra(EXTRA_DESTINATION, mdes);
        intent.putExtra(EXTRA_MLAT, mlat);
        intent.putExtra(EXTRA_MLNG, mlng);
        intent.putExtra(EXTRA_MDES, destinationMeters);
        startService(intent);
        bindService(intent, conn, Context.BIND_AUTO_CREATE);
    }
}

From source file:gov.nasa.arc.geocam.geocam.CameraActivity.java

@Override
public void onResume() {
    super.onResume();

    mServiceBound = bindService(new Intent(this, GeoCamService.class), mServiceConn, Context.BIND_AUTO_CREATE);
    if (!mServiceBound) {
        Log.e(GeoCamMobile.DEBUG_ID, "CameraActivity::onResume - error binding to service");
    }/*ww w  .  ja va 2 s .co  m*/

    mForeground.foreground();

    mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_GAME);
    mSensorManager.registerListener(mSensorListener,
            mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_GAME);

    mLatText.setText("Lat: unavailable");
    mLonText.setText("Lon: unavailable");

    IntentFilter filter = new IntentFilter(GeoCamMobile.LOCATION_CHANGED);
    this.registerReceiver(mLocationReceiver, filter);

    if (getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
        showDialog(DIALOG_HIDE_KEYBOARD);
    }

    // Unset focus and picture status flags when returning from another activity
    mLensIsFocused = false;
    mPictureTaken = false;
}

From source file:com.digitalarx.android.authentication.AuthenticatorActivity.java

/**
 * {@inheritDoc}//from  w  w w  .j ava2 s.  c o m
 * 
 * IMPORTANT ENTRY POINT 1: activity is shown to the user
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    //Log_OC.wtf(TAG,  "onCreate init");
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    // bind to Operations Service
    mOperationsServiceConnection = new OperationsServiceConnection();
    if (!bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
            Context.BIND_AUTO_CREATE)) {
        Toast.makeText(this, R.string.error_cant_bind_to_operations_service, Toast.LENGTH_LONG).show();
        finish();
    }

    /// init activity state
    mAccountMgr = AccountManager.get(this);
    mNewCapturedUriFromOAuth2Redirection = null;

    /// get input values
    mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE);
    mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);
    if (savedInstanceState == null) {
        initAuthTokenType();
    } else {
        mAuthTokenType = savedInstanceState.getString(KEY_AUTH_TOKEN_TYPE);
        mWaitingForOpId = savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID);
    }

    /// load user interface
    setContentView(R.layout.account_setup);

    /// initialize general UI elements
    initOverallUi(savedInstanceState);

    mOkButton = findViewById(R.id.buttonOK);

    /// initialize block to be moved to single Fragment to check server and get info about it 
    initServerPreFragment(savedInstanceState);

    /// initialize block to be moved to single Fragment to retrieve and validate credentials 
    initAuthorizationPreFragment(savedInstanceState);

    //Log_OC.wtf(TAG,  "onCreate end");
}

From source file:com.cerema.cloud2.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  a  2s.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));
        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:src.com.nustats.pacelogger.RecordingActivity.java

void setListener() {
    Intent rService = new Intent(this, RecordingService.class);
    ServiceConnection sc = new ServiceConnection() {
        public void onServiceDisconnected(ComponentName name) {
        }/*from   w w  w .  ja  v  a 2s.  co m*/

        public void onServiceConnected(ComponentName name, IBinder service) {
            IRecordService rs = (IRecordService) service;
            if (RecordingActivity.this.isRecording) {
                rs.resumeRecording();
            } else {
                rs.pauseRecording();
            }
            unbindService(this);
        }
    };
    // This should block until the onServiceConnected (above) completes, but doesn't
    bindService(rService, sc, Context.BIND_AUTO_CREATE);
}

From source file:com.jiusg.mainscreenshow.ui.MSS.java

@Override
protected void onStart() {
    super.onStart();
    Intent service = new Intent(MSS.this, MSSService.class);
    this.getApplicationContext().bindService(service, mSc, Context.BIND_AUTO_CREATE);
}

From source file:gov.nasa.arc.geocam.geocam.GeoCamMobile.java

@Override
public void onResume() {
    super.onResume();
    Log.d(DEBUG_ID, "GeoCamMobile::onResume called");

    mForeground.foreground();//from   ww  w . j  a v  a  2  s  .c  o m

    mServiceBound = bindService(new Intent(this, GeoCamService.class), mServiceConn, Context.BIND_AUTO_CREATE);
    if (!mServiceBound) {
        Log.e(DEBUG_ID, "GeoCamMobile::onResume - error binding to service");
    }

    IntentFilter filter = new IntentFilter(GeoCamMobile.LOCATION_CHANGED);
    this.registerReceiver(mLocationReceiver, filter);

    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        showDialog(DIALOG_GPS_OFF_ID);
    }
}

From source file:com.nextgis.mobile.MainActivity.java

void startGPXRecord() {
    startService(new Intent(TrackerService.ACTION_START_GPX));

    bindService(new Intent(this, TrackerService.class), m_oConnection, Context.BIND_AUTO_CREATE);
}

From source file:io.github.data4all.activity.CameraActivity.java

@Override
protected void onResume() {
    super.onResume();
    this.setLayout();
    if (this.isDeviceSupportCamera()) {
        try {/*from  w w  w  .j  a  va 2 s  . co  m*/
            cameraPreview = (CameraPreview) findViewById(R.id.cameraPreview);

            mCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
            cameraPreview.setCamera(mCamera);
            mCamera.startPreview();
            this.setListener(btnCapture);
        } catch (RuntimeException ex) {
            Toast.makeText(getApplicationContext(), getString(R.string.noCamSupported), Toast.LENGTH_LONG)
                    .show();
            Log.e(TAG, "device supports no camera", ex);
        }
    } else {
        Toast.makeText(getApplicationContext(), getString(R.string.noCamSupported), Toast.LENGTH_LONG).show();
        finish();
        Log.d(TAG, "device supports no camera");
        return;
    }
    listener.enable();
    Intent intent = new Intent(this, OrientationListener.class);
    bindService(intent, orientationListenerConnection, Context.BIND_AUTO_CREATE);
    this.startService(intent);
}