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.zentri.otademo.OTAActivity.java
@Override protected void onStart() { super.onStart(); if (mLocalBroadcastManager != null) { Intent intent = new Intent(this, ZentriOSBLEService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); startTimeout(mServiceConnectionTimeoutTask, TIMEOUT_SERVICE_CON_MS); mLocalBroadcastManager.registerReceiver(mBroadcastReceiver, mReceiverIntentFilter); } else {//from ww w . j ava 2s .co m setStatusError(getString(R.string.error_connection_setup)); } }
From source file:com.gamethrive.TrackGooglePurchase.java
void trackIAP() { if (mServiceConn == null) { mServiceConn = new ServiceConnection() { @Override/* www. ja v a 2 s .c o m*/ public void onServiceDisconnected(ComponentName name) { iapEnabled = -99; mIInAppBillingService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { try { Class<?> stubClass = Class.forName("com.android.vending.billing.IInAppBillingService$Stub"); Method asInterfaceMethod = stubClass.getMethod("asInterface", android.os.IBinder.class); mIInAppBillingService = asInterfaceMethod.invoke(null, service); QueryBoughtItems(); } catch (Throwable t) { t.printStackTrace(); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); appContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else if (mIInAppBillingService != null) QueryBoughtItems(); }
From source file:com.stephenmcgruer.simpleupnp.fragments.FileBrowserFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDeviceUdn = getArguments().getString(ARGS_UDN); if (mDeviceUdn == null || mDeviceUdn.isEmpty()) throw new IllegalStateException("FileBrowserFragment requires a Device UDN"); mContainerMap = new HashMap<>(); mContainerMap.put(ContainerWrapper.ROOT_CONTAINER_ID, ContainerWrapper.ROOT_CONTAINER); mCurrentContainer = ContainerWrapper.ROOT_CONTAINER; if (getArguments().getString(ARGS_INITIAL_CONTAINER_ID) != null) { ContainerWrapper wrapper = new ContainerWrapper("Bookmark", getArguments().getString(ARGS_INITIAL_CONTAINER_ID), BOOKMARK_PARENT_ID); mContainerMap.put(wrapper.getId(), wrapper); mCurrentContainer = wrapper;//from ww w . j a va 2 s .com } // TODO(smcgruer): Handle failure gracefully. if (!getActivity().getApplicationContext().bindService( new Intent(getActivity(), AndroidUpnpServiceImpl.class), this, Context.BIND_AUTO_CREATE)) { throw new IllegalStateException("Unable to bind AndroidUpnpServiceImpl"); } }
From source file:edu.asu.cse535.assignment3.MainActivity.java
public void onStartRecordingRunning(View v) { Log.w(this.getClass().getSimpleName(), "Button is clicked"); intent = new Intent(MainActivity.this.getBaseContext(), AccIntentService.class); intent.putExtra("activity", Constants.ACTIVITY_RUNNING); startService(intent);/*from www . j a v a 2s. c om*/ serve = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { accIntentService = ((AccIntentService.LocalBinder) service).getInstance(); accIntentService.setHandler(handler); Log.w(this.getClass().getSimpleName(), "Activity is connected to service"); } @Override public void onServiceDisconnected(ComponentName name) { } }; bindService(intent, serve, Context.BIND_AUTO_CREATE); }
From source file:com.mbientlab.metawear.app.ModuleListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Activities containing this fragment must implement its callbacks. if (!(activity instanceof Callbacks)) { throw new IllegalStateException("Activity must implement fragment's callbacks."); }//from w ww .j a v a2 s.c o m mCallbacks = (Callbacks) activity; activity.getApplicationContext().bindService(new Intent(activity, MetaWearBleService.class), this, Context.BIND_AUTO_CREATE); }
From source file:hku.fyp14017.blencode.stage.DroneConnection.java
private void helpBindDroneService() throws RuntimeException { if (droneControlService == null && !stageActivityContext.bindService(new Intent(stageActivityContext, DroneControlService.class), this.droneServiceConnection, Context.BIND_AUTO_CREATE)) { throw new RuntimeException("Connection to the drone not successful"); }/*from w w w .j a v a 2 s . com*/ }
From source file:com.ecocitizen.service.SensorMapUploaderService.java
private void connectDeviceManager() { // Start the service if not already running startService(new Intent(IDeviceManagerService.class.getName())); // Establish connection with the service. bindService(new Intent(IDeviceManagerService.class.getName()), mConnection, Context.BIND_AUTO_CREATE); }
From source file:com.flat20.fingerplay.FingerPlayActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // Init needs to be done first! mSettingsModel = SettingsModel.getInstance(); mSettingsModel.init(this); mMidiControllerManager = MidiControllerManager.getInstance(); super.onCreate(savedInstanceState); Runtime r = Runtime.getRuntime(); r.gc();/*from w w w. j av a 2s .co m*/ Toast info = Toast.makeText(this, "Go to http://goddchen.github.io/Fingerplay-Midi/ for help.", Toast.LENGTH_LONG); info.show(); // Sensor code sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); sensors = new ArrayList<Sensor>(sensorManager.getSensorList(Sensor.TYPE_ALL)); startSensors(); // Simple splash animation Splash navSplash = new Splash(mNavigationOverlay, 64, 30, mWidth, mNavigationOverlay.x); mNavigationOverlay.x = mWidth; AnimationManager.getInstance().add(navSplash); Splash mwcSplash = new Splash(mMidiWidgetsContainer, 64, 40, -mWidth, mMidiWidgetsContainer.x); mMidiWidgetsContainer.x = -mWidth; AnimationManager.getInstance().add(mwcSplash); if (BuildConfig.DEBUG) { if (TextUtils.isEmpty(PreferenceManager.getDefaultSharedPreferences(this) .getString("settings_server_address", null))) { Toast.makeText(this, R.string.toast_server_not_setup, Toast.LENGTH_SHORT).show(); startActivity(new Intent(getApplicationContext(), SettingsView.class)); } } else { boolean result = bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mBillingServiceConnection, Context.BIND_AUTO_CREATE); if (!result) { unableToVerifyLicense(getString(R.string.billing_error_init), false); } } }
From source file:com.arcusapp.soundbox.fragment.PlayFragment.java
private void bindMediaPlayerService() { myServiceConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder binder) { mediaService = ((MediaPlayerService.MyBinder) binder).getService(); mediaService.registerListener(serviceListener); updateUI();/*from w w w . j a va2 s . c o m*/ initRunnableSeekBar(); } public void onServiceDisconnected(ComponentName className) { mediaService = null; } }; Intent serviceIntent = new Intent(SoundBoxApplication.ACTION_MEDIA_PLAYER_SERVICE, null, SoundBoxApplication.getContext(), MediaPlayerService.class); getActivity().bindService(serviceIntent, myServiceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.omniwearhaptics.api.OmniWearHelper.java
public OmniWearHelper(final Context context, OnOmniWearEventListener eventListener, OnOmniWearLogListener logListener) { mParent = context;/*from w ww . ja va2 s . c om*/ mOnOmniWearEventListener = eventListener; mOnOmniWearLogListener = logListener; Intent intent = new Intent(); intent.setClassName("com.omniwearhaptics.omniwearbtbridge", "com.omniwearhaptics.omniwearbtbridge.OmniWearService"); permissionsCheck(); // Connect to the OmniWear service. mServiceConnection = new ServiceConnection() { // When the service is bound, try to connect to the device. public void onServiceConnected(ComponentName name, IBinder service) { // Create the interface. mOmniWearInterface = IOmniWear.Stub.asInterface(service); // Register the callback. if (mCallback != null) { try { if (mOmniWearInterface != null) { mOmniWearInterface.registerCallback(mCallback); mCallback.onOmniWearEvent(EVENT_SERVICE_BOUND); } } catch (RemoteException e) { e.printStackTrace(); } } else { Log.w(TAG, "mCallback is null in searchForOmniWearDevice"); } } public void onServiceDisconnected(ComponentName name) { try { mOmniWearInterface.unregisterCallback(); } catch (RemoteException e) { e.printStackTrace(); } } }; context.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); }