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.concavenp.artistrymuse.MainActivity.java
@Override protected void onStart() { super.onStart(); // Bind to LocalService Intent intent = new Intent(this, UserAuthenticationService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); // Read in the current tab location from the Shared Preferences and select that tab SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); int position = sharedPref.getInt(TAB_POSITION, DEFAULT_TAB_POSITION); TabLayout.Tab tab = tabLayout.getTabAt(position); // Verify there is a tab to work with if (tab != null) { tab.select();/*from w w w . ja va2s . co m*/ } }
From source file:dk.bearware.gui.MainActivity.java
@Override protected void onStart() { super.onStart(); if (ttsWrapper == null) ttsWrapper = TTSWrapper.getInstance(this); if (mConnection == null) mConnection = new TeamTalkConnection(this); if (!mConnection.isBound()) { // Bind to LocalService Intent intent = new Intent(getApplicationContext(), TeamTalkService.class); Log.d(TAG, "Binding TeamTalk service"); if (!bindService(intent, mConnection, Context.BIND_AUTO_CREATE)) Log.e(TAG, "Failed to bind to TeamTalk service"); } else {/*from w w w.jav a 2s .c o m*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); int mastervol = prefs.getInt(Preferences.PREF_SOUNDSYSTEM_MASTERVOLUME, SoundLevel.SOUND_VOLUME_DEFAULT); int gain = prefs.getInt(Preferences.PREF_SOUNDSYSTEM_MICROPHONEGAIN, SoundLevel.SOUND_GAIN_DEFAULT); int voxlevel = prefs.getInt(Preferences.PREF_SOUNDSYSTEM_VOICEACTIVATION_LEVEL, 5); boolean voxState = ttservice.isVoiceActivationEnabled(); boolean txState = ttservice.isVoiceTransmitting(); // only set volume and gain if tt-instance hasn't already been configured if (ttclient.getSoundOutputVolume() != mastervol) ttclient.setSoundOutputVolume(mastervol); if (ttclient.getSoundInputGainLevel() != gain) ttclient.setSoundInputGainLevel(gain); if (ttclient.getVoiceActivationLevel() != voxlevel) ttclient.setVoiceActivationLevel(voxlevel); adjustMuteButton((ImageButton) findViewById(R.id.speakerBtn)); adjustVoxState(voxState, voxState ? voxlevel : gain); adjustTxState(txState); TextView volLevel = (TextView) findViewById(R.id.vollevel_text); volLevel.setText(Utils.refVolumeToPercent(mastervol) + "%"); volLevel.setContentDescription(getString(R.string.speaker_volume_description, volLevel.getText())); } }
From source file:com.nps.micro.MainActivity.java
private void bindToUsbService() { if (!isBoundToService && isDeviceAvailable) { Log.d(TAG, "Binding nps usb service..."); isBoundToService = bindService(new Intent(this, UsbService.class), usbServiceConnection, Context.BIND_AUTO_CREATE); }/*from w w w . ja v a 2s . c o m*/ }
From source file:com.luan.thermospy.android.activities.MainActivity.java
public boolean startBackgroundService() { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); int interval = Integer.parseInt(settings.getString(getString(R.string.pref_key_refresh_interval), "5")); if (!isMyServiceRunning(TemperatureMonitorService.class)) { // Bind to LocalService Intent intent = new Intent(this, TemperatureMonitorService.class); Bundle bundle = new Bundle(); bundle.putString(TemperatureMonitorService.ServiceArguments.IP_ADDRESS, Coordinator.getInstance().getServerSettings().getIpAddress()); bundle.putInt(TemperatureMonitorService.ServiceArguments.PORT, Coordinator.getInstance().getServerSettings().getPort()); bundle.putInt(TemperatureMonitorService.ServiceArguments.REFRESH_RATE, interval); intent.putExtras(bundle);//w ww.j av a 2 s . co m startService(intent); } if (isMyServiceRunning(TemperatureMonitorService.class) && !mBound) { // Create bind to service Intent intent = new Intent(this, TemperatureMonitorService.class); Bundle bundle = new Bundle(); bundle.putInt(TemperatureMonitorService.ServiceArguments.ALARM, Integer.parseInt(Coordinator.getInstance().getAlarmSettings().getAlarm())); bundle.putInt(TemperatureMonitorService.ServiceArguments.ALARM_CONDITION, Coordinator.getInstance().getAlarmSettings().getAlarmCondition().getId()); bundle.putInt(TemperatureMonitorService.ServiceArguments.REFRESH_RATE, interval); bundle.putBoolean(TemperatureMonitorService.ServiceArguments.ALARM_ENABLED, Coordinator.getInstance().getAlarmSettings().isAlarmSwitchEnabled()); intent.putExtras(bundle); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } return true; }
From source file:de.qspool.clementineremote.ui.ConnectActivity.java
/** * Connect to clementine// ww w. j av a2 s .co m */ private void connect() { // Do not connect if the activity has finished! if (this.isFinishing()) { return; } if (!mKnownIps.contains(mEtIp.getText().toString())) { mKnownIps.add(mEtIp.getText().toString()); } final String ip = mEtIp.getText().toString(); // Save the data SharedPreferences.Editor editor = mSharedPref.edit(); editor.putString(SharedPreferencesKeys.SP_KEY_IP, ip); editor.putInt(SharedPreferencesKeys.SP_LAST_AUTH_CODE, mAuthCode); editor.putStringSet(SharedPreferencesKeys.SP_KNOWN_IP, mKnownIps); editor.apply(); // Create a progress dialog mPdConnect = new MaterialDialog.Builder(this).cancelable(true).cancelListener(oclProgressDialog) .content(R.string.connectdialog_connecting).progress(true, -1).show(); // Start the service so it won't be stopped on unbindService Intent serviceIntent = new Intent(this, ClementineService.class); startService(serviceIntent); bindService(serviceIntent, new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { ClementineService.ClementineServiceBinder clementineServiceBinder = (ClementineService.ClementineServiceBinder) service; clementineServiceBinder.getClementineService().setUiHandler(mHandler); Intent connectIntent = new Intent(ConnectActivity.this, ClementineService.class); connectIntent.putExtra(ClementineService.SERVICE_ID, ClementineService.SERVICE_START); connectIntent.putExtra(ClementineService.EXTRA_STRING_IP, ip); connectIntent.putExtra(ClementineService.EXTRA_INT_PORT, getPort()); connectIntent.putExtra(ClementineService.EXTRA_INT_AUTH, mAuthCode); clementineServiceBinder.getClementineService().handleServiceAction(connectIntent); unbindService(this); } @Override public void onServiceDisconnected(ComponentName name) { } }, Context.BIND_AUTO_CREATE); }
From source file:com.hardcopy.retrowatch.RetroWatchActivity.java
private void doStartService() { Logs.d(TAG, "# Activity - doStartService()"); startService(new Intent(this, RetroWatchService.class)); bindService(new Intent(this, RetroWatchService.class), mServiceConn, Context.BIND_AUTO_CREATE); }
From source file:com.baruckis.nanodegree.spotifystreamer.fragments.PlayerDialogFragment.java
private void onInitService() { Intent playIntent = new Intent(getActivity(), PlayerService.class); getActivity().startService(playIntent); getActivity().bindService(playIntent, mPlayerConnection, Context.BIND_AUTO_CREATE); App app = ((App) getActivity().getApplication()); app.setIsNowPlaying(true);/*from ww w. j a v a2 s . com*/ }
From source file:com.beestar.ble.ble.ui.MultipleBleActivity.java
private void doBindService() { Intent serviceIntent = new Intent(this, MultipleBleService.class); bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:jp.mixi.android.sdk.MixiContainerImpl.java
private boolean bindRemoteService(ContextWrapper context, Intent intent, ServiceConnection connection) { return context.bindService(intent, connection, Context.BIND_AUTO_CREATE); }
From source file:com.zld.ui.ZldNewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { instance = this; initSqliteManager();/* ww w .ja va2 s. com*/ // initvz(); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.zld_new_layout); // Intent intent = new Intent(this, DetectionServerService.class); // /** Activity? */ // bindService(intent, conn, Context.BIND_AUTO_CREATE); Intent intentPoll = new Intent(this, PollingService.class); // ? ??? bindService(intentPoll, connPoll, Context.BIND_AUTO_CREATE); initvz(); ((application) getApplication()).setZldNewActivity(this); initImei(); initView(); initDevices(); initLEDs(); setLedConn(); startPollService(); getChargeInfo(); initCameraInfo(); initTimer(); getCameraIpOutPassid(); getCameraInList(); getCameraOutList(); getLedCameraIpIn(); getLedCameraIpOut(); /* ???? */ hideFreeAndChargeBtn(); passid = getPassid(); satrtTiming(); //? handler.sendEmptyMessageDelayed(Constant.KEEP_TIME, 10000); // handlerNumber.postDelayed(runnable, 5000); berthHandler = new BerthHandler(this); berthHandler.sendEmptyMessageDelayed(Constant.BerthHandlerWhat, 5000); FileUtil.writeSDFile("", "379-->" + System.currentTimeMillis()); }