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.haarman.listviewanimations.MainActivity.java

@SuppressLint("InlinedApi")
@Override//from w ww . ja va 2 s.  c  o m
protected void onCreate(final Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn,
            Context.BIND_AUTO_CREATE);
}

From source file:com.github.michalbednarski.intentslab.sandbox.SandboxManager.java

public static void initSandboxAndRunWhenReady(Context context, Runnable whenReady) {
    if (BuildConfig.DEBUG && sRefCount == 0) {
        throw new AssertionError("initSandboxAndRunWhenReady called without refSandbox");
    }/*from  w ww .  j a  v a2  s  .c om*/
    if (isReady()) {
        whenReady.run();
    } else if (sSandboxReadyCallbacks != null) {
        sSandboxReadyCallbacks.add(whenReady);
    } else {
        sSandboxReadyCallbacks = new ArrayList<Runnable>(1);
        sSandboxReadyCallbacks.add(whenReady);
        if (sApplicationContext == null) {
            sApplicationContext = context.getApplicationContext();
        }
        sApplicationContext.bindService(new Intent().setClassName(SANDBOX_PACKAGE, SANDBOX_SERVICE_CLASS),
                sServiceConnection, Context.BIND_AUTO_CREATE);
    }
}

From source file:com.vsc.google.api.services.samples.calendar.android.bilik.BaseActivity.java

void doBindServices() {
    bindService(new Intent(this, CalendarService.class), calendarServiceConnection, Context.BIND_AUTO_CREATE);
    isBound = true;
}

From source file:edu.umich.oasis.client.OASISConnection.java

public static ServiceConnection bind(final Context context, final Callback callback) {
    final ServiceConnection connection = new ServiceConnection() {
        private OASISConnection conn;

        @Override/*from  www .  j a  v  a 2  s . c  o m*/
        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            IOASISService service = IOASISService.Stub.asInterface(iBinder);
            conn = new OASISConnection(context, this, service);
            try {
                callback.onConnect(conn);
            } catch (Exception e) {
                Log.e(TAG, "Unhandled exception in onConnect", e);
            }
        }

        @Override
        public void onServiceDisconnected(ComponentName componentName) {
            Log.e(TAG, "Lost Binder connection to OASIS");
            if (callback instanceof DisconnectCallback) {
                try {
                    ((DisconnectCallback) callback).onDisconnect(conn);
                } catch (Exception e) {
                    Log.e(TAG, "Unhandled exception in onDisconnect", e);
                }
            }
            conn.closeInternal();
        }
    };

    Intent serviceIntent = new Intent();
    serviceIntent.setComponent(OASISFramework.getServiceComponent(context));
    if (context.bindService(serviceIntent, connection, Context.BIND_AUTO_CREATE
            | Context.BIND_ADJUST_WITH_ACTIVITY | Context.BIND_ABOVE_CLIENT | Context.BIND_IMPORTANT)) {
        return connection;
    } else {
        return null;
    }
}

From source file:com.secupwn.aimsicd.ui.fragments.DeviceFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mContext = getActivity().getBaseContext();
    // Bind to LocalService
    Intent intent = new Intent(mContext, AimsicdService.class);
    mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

    swipeRefreshLayout.setOnRefreshListener(this);
}

From source file:com.coinblesk.client.wallet.WalletActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wallet);
    initViewPager();/*from  w ww .  j a  v  a2s  . c o m*/
    initToolbar();

    Intent walletServiceIntent = new Intent(this, WalletService.class);
    startService(walletServiceIntent);
    bindService(walletServiceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
}

From source file:edu.illinois.whereru.MainTabFragmentActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(DEBUG_TAG, "onCreate");

    setContentView(R.layout.activity_main_tab);
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

    mTabHost.addTab(mTabHost.newTabSpec("map").setIndicator("Map"), GoogleMapFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("friendList").setIndicator("Friends"), FriendListFragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("friendRequest").setIndicator("Friend Requests"),
            FriendRequestListFragment.class, null);

    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
    }/*w w  w .j a v  a 2s.com*/

    // Starting location manager service
    Intent intent = new Intent(this, LocationManagerService.class);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    startService(intent);

}

From source file:com.tangrainc.inappbilling.InAppBillingHelper.java

public InAppBillingHelper(Context context, String[] productIdentifiers) {
    _executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
    _productIdentifiers = productIdentifiers;
    _context = context;/* w ww . j a  va2 s  .c o  m*/
    ServiceConnection _serviceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            Log.d(TAG, "Billing Service disconnected.");
            _service = null;
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            Log.d(TAG, "Billing Service connected.");
            _service = IInAppBillingService.Stub.asInterface(service);
        }
    };

    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    _context.bindService(serviceIntent, _serviceConn, Context.BIND_AUTO_CREATE);
}

From source file:com.packpublishing.asynchronousandroid.chapter5.Sha1BroacastActivity.java

@Override
protected void onStart() {
    super.onStart();
    // Bind to LocalService
    Intent intent = new Intent(this, Sha1HashBroadcastService.class);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
    mReceiver.attach((TextView) findViewById(R.id.hashResult));
    IntentFilter filter = new IntentFilter(Sha1HashBroadcastService.DIGEST_BROADCAST);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
}

From source file:com.thunder.iap.IAPActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.activity_main);
    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
}