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.schoentoon.connectbot.PubkeyListActivity.java

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

    bindService(new Intent(this, TerminalManager.class), connection, Context.BIND_AUTO_CREATE);

    if (pubkeydb == null)
        pubkeydb = new PubkeyDatabase(this);
}

From source file:com.sonetel.ui.calllog.CallLogListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {

    getActivity().bindService(new Intent(SipManager.INTENT_SIP_SERVICE), connection, Context.BIND_AUTO_CREATE);
    return inflater.inflate(R.layout.call_log_fragment, container, false);

}

From source file:com.google.android.apps.location.gps.gnsslogger.LoggerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View newView = inflater.inflate(R.layout.fragment_log, container, false /* attachToRoot */);

    mLogView = (TextView) newView.findViewById(R.id.log_view);
    mScrollView = (ScrollView) newView.findViewById(R.id.log_scroll);

    getActivity().bindService(new Intent(getActivity(), TimerService.class), mConnection,
            Context.BIND_AUTO_CREATE);

    UiLogger currentUiLogger = mUiLogger;
    if (currentUiLogger != null) {
        currentUiLogger.setUiFragmentComponent(mUiComponent);
    }/*from www  .  j a va 2 s.c  o  m*/
    FileLogger currentFileLogger = mFileLogger;
    if (currentFileLogger != null) {
        currentFileLogger.setUiComponent(mUiComponent);
    }

    Button start = (Button) newView.findViewById(R.id.start_log);
    Button end = (Button) newView.findViewById(R.id.end_log);
    Button clear = (Button) newView.findViewById(R.id.clear_log);

    start.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            mScrollView.fullScroll(View.FOCUS_UP);
        }
    });

    end.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            mScrollView.fullScroll(View.FOCUS_DOWN);
        }
    });

    clear.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            mLogView.setText("");
        }
    });

    mTimerDisplay = (TextView) newView.findViewById(R.id.timer_display);
    mTimer = (Button) newView.findViewById(R.id.timer);
    mStartLog = (Button) newView.findViewById(R.id.start_logs);
    mSendFile = (Button) newView.findViewById(R.id.send_file);

    displayTimer(mTimerValues, false /* countdownStyle */);
    enableOptions(true /* start */);

    mStartLog.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            enableOptions(false /* start */);
            Toast.makeText(getContext(), R.string.start_message, Toast.LENGTH_LONG).show();
            mFileLogger.startNewLog();

            if (!mTimerValues.isZero() && (mTimerService != null)) {
                mTimerService.startTimer();
            }
        }
    });

    mSendFile.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            stopAndSend();
        }
    });

    mTimer.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            launchTimerDialog();
        }
    });

    return newView;
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.ZipFlashingOutputFragment.java

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

    // Create terminal
    mSession = new TermSession();
    // We don't care about any input because this is kind of a "dumb" terminal output, not
    // a proper interactive one
    mSession.setTermOut(new NullOutputStream());

    mOS = new PipedOutputStream();
    try {/*w  w w .  j  av a  2  s  .  c  o  m*/
        mSession.setTermIn(new PipedInputStream(mOS));
    } catch (IOException e) {
        e.printStackTrace();
    }

    mEmulatorView.attachSession(mSession);

    // Start and bind to the service
    Intent intent = new Intent(getActivity(), SwitcherService.class);
    getActivity().bindService(intent, this, Context.BIND_AUTO_CREATE);
    getActivity().startService(intent);
}

From source file:ack.me.truconnectandroiddemo.DeviceInfoActivity.java

@Override
protected void onStart() {
    super.onStart();

    Intent serviceIntent = new Intent(getApplicationContext(), TruconnectService.class);
    bindService(serviceIntent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.cyanogenmod.effem.FmRadio.java

/**
 * Starts up the listeners and the FM radio if it isn't already active
 *//*  w  ww  . j  av  a 2s .c o  m*/
@Override
protected void onResume() {
    super.onResume();
    Log.i(LOG_TAG, "onResume");

    // start and bind to service
    startService(new Intent(this, FmRadioService.class));
    bindService(new Intent(this, FmRadioService.class), this, Context.BIND_AUTO_CREATE);
}

From source file:com.jetheis.android.grades.billing.googleplay.GooglePlayBillingWrapper.java

public GooglePlayBillingWrapper(Context context) {
    mContext = context;//from www.  ja  va2s.co  m
    mOnReadyListeners = new HashSet<OnBillingReadyListener>();
    mOnPurchaseStateChangedListeners = new HashSet<OnPurchaseStateChangedListener>();

    mContext.startService(new Intent(mContext, GooglePlayBillingService.class));

    mConnection = new ServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            mBoundService = ((GooglePlayBillingService.GooglePlayBillingBinder) service).getService();
            mBoundService.checkIsBillingSupported(new OnGooglePlayBillingSupportResultListener() {

                @Override
                public void onGooglePlayBillingSupportResultFound(boolean billingSupported) {
                    if (billingSupported) {
                        Log.i(Constants.TAG, "Google Play billing ready");

                        for (OnBillingReadyListener listener : mOnReadyListeners) {
                            listener.onBillingReady();
                        }

                    } else {
                        Log.i(Constants.TAG, "Google Play billing is not supported");

                        for (OnBillingReadyListener listener : mOnReadyListeners) {
                            listener.onBillingNotSupported();
                        }

                    }
                }

            });

        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            mBoundService = null;
        }
    };

    mContext.bindService(new Intent(context, GooglePlayBillingService.class), mConnection,
            Context.BIND_AUTO_CREATE);
}

From source file:com.example.helloworldlinked.backend.HelloWorldService.java

private void bindToProviderService(Context context) {
    Utility.logDebug(TAG, "bindToProviderService");
    Intent intent = new Intent(HELLO_WORLD_PROVIDER_SERVICE_NAME);
    context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}

From source file:me.diskstation.ammon.gpsrunner.ui.DrawerActivity.java

public boolean startLocationService(OverviewFragment overviewFragment) {
    if (!mBound) {
        //TODO: add permission management for Android M
        if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
            Intent intent = new Intent(this, me.diskstation.ammon.gpsrunner.service.LocationService.class);
            boolean successful = bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
            System.out.println(successful);
            return successful;
        } else {//  ww w  .  ja  va2 s. c om
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_CONTACTS },
                    ACCESS_LOCATION_FINE_REQUEST);
            return false;
        }
    } else {
        return false;
    }
}

From source file:devicroft.burnboy.Activities.MainActivity.java

private void initialiseService() {
    Log.d(LOG_TAG, "initService");
    this.startService(new Intent(this, LogService.class));
    this.bindService(new Intent(this, LogService.class), serviceConnection, Context.BIND_AUTO_CREATE);
}