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:edu.pdx.cecs.orcycle.MyApplication.java
/** * Connects the recording service to the Application object *//*w ww .j a v a2 s . co m*/ private void ConnectRecordingService() { try { Intent intent = new Intent(this, RecordingService.class); bindService(intent, recordingServiceServiceConnection, Context.BIND_AUTO_CREATE); } catch (SecurityException ex) { Log.d(MODULE_TAG, ex.getMessage()); } }
From source file:com.hardcopy.arduinonavi.MainActivity.java
/** * Start service if it's not running/*from w ww .j av a 2 s . co m*/ */ private void doStartService() { Log.d(TAG, "# Activity - doStartService()"); startService(new Intent(this, ArduinoNavigatorService.class)); bindService(new Intent(this, ArduinoNavigatorService.class), mServiceConn, Context.BIND_AUTO_CREATE); }
From source file:com.android.gallery3d.app.AbstractGalleryActivity.java
private void doBindBatchService() { bindService(new Intent(this, BatchService.class), mBatchServiceConnection, Context.BIND_AUTO_CREATE); mBatchServiceIsBound = true;//from www . j a v a 2s .co m }
From source file:uk.org.openseizuredetector.MainActivity.java
/** * bind to an already running server./*from w w w .j a va2 s . co m*/ */ private void bindToServer() { Log.v(TAG, "bindToServer() - binding to SdServer"); Intent intent = new Intent(this, SdServer.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:com.hardcopy.retroband.MainActivity.java
/** * Start service if it's not running/*from w w w . j ava 2 s . com*/ */ private void doStartService() { Log.d(TAG, "# Activity - doStartService()"); startService(new Intent(this, RetroBandService.class)); bindService(new Intent(this, RetroBandService.class), mServiceConn, Context.BIND_AUTO_CREATE); }
From source file:com.synox.android.ui.activity.FileActivity.java
/** * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of * the {@link FileActivity}./*ww w.j a va 2 s .c om*/ * <p/> * 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:com.rareventure.gps2.reviewer.wizard.WelcomePage.java
public void moveTrialDataToPremiumDir(final WTask wTask) { isMoveTrialRunning = true;/*from w w w.j av a 2 s . c om*/ Intent i = new Intent(ITrialService.class.getName()).setPackage(GTG.TRIAL_APPLICATION_PACKAGE); boolean boundSuccessfully = true; ServiceConnection serviceConnection = null; try { if (!bindService(i, serviceConnection = new ServiceConnection() { private boolean serviceAlreadyConnected; @Override public void onServiceDisconnected(ComponentName name) { } @Override public void onServiceConnected(ComponentName name, IBinder service) { try { Log.d(GTG.TAG, "welcome page: service connected"); if (serviceAlreadyConnected) return; serviceAlreadyConnected = true; ITrialService mService = ITrialService.Stub.asInterface(service); Map<String, Object> prefsMap = mService.giveMePreferences(); String trialDirString = mService.getExtFileDir(); Log.d(GTG.TAG, "welcome page: got ext file dir"); // we don't worry about synchronization here, because we only do this during // initial setup GTG.prefSet.loadAndroidPreferencesFromMap(WelcomePage.this, prefsMap); GTG.prefSet.saveSharedPrefs(WelcomePage.this); mService.notifyReplaced(); //shutdown the trial app commpletely before we start moving the files try { mService.shutdown(); } catch (Exception e) { //an exception is thrown because it kills the process Log.i(GTG.TAG, "Trial shutdown"); } File trialDir = new File(trialDirString); File myFileDir = GTG.getExternalStorageDirectory(); for (File subFile : trialDir.listFiles()) { //we don't freak out on failure here. Hopefully gps.db3 will be moved at least. //if not, a new db will be created with no points if (!subFile.renameTo(new File(myFileDir + "/" + subFile.getName()))) Log.e(GTG.TAG, "Couldn't move file " + subFile + " to " + myFileDir); } } catch (Exception e) { Log.e(GTG.TAG, "Error trying to move trial data", e); } wTask.notifyFinish(); //restart startReviewer now that we may have trial data runOnUiThread(new Runnable() { public void run() { startWelcomePage(true); } }); unbindService(this); //we restart the trial app, so that it will shut off the notification frog. Since we kill it before we //moved the files away, it didn't have time to shut it off itself. Intent i = new Intent(GpsTrailerReceiver.class.getName()) .setPackage(GTG.TRIAL_APPLICATION_PACKAGE); Log.d(GTG.TAG, "Sending broadcast to " + i + ", name " + GpsTrailerReceiver.class.getName()); sendBroadcast(i); } }, Context.BIND_AUTO_CREATE)) boundSuccessfully = false; } catch (Exception e) { Log.e(GTG.TAG, "Exception trying to bind service", e); boundSuccessfully = false; } finally { } if (!boundSuccessfully) { Log.d(GTG.TAG, "welcome page: could not bind service"); wTask.notifyFinish(); isMoveTrialRunning = false; startWelcomePage(true); //even if we don't bind the service, we still have to unbind or android complains about a leaked service connection if (serviceConnection != null) unbindService(serviceConnection); } }
From source file:com.artur.softwareproject.Main.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.disconnect: if (!recording) { stopService(bluetoothServiceIntent); final ProgressDialog disconnectingDialog = new ProgressDialog(Main.this); disconnectingDialog.setMessage("Disconnecting..."); disconnectingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); disconnectingDialog.setCancelable(false); disconnectingDialog.show();//from w ww. ja v a 2s . c o m disconDialog = disconnectingDialog; final DisconnectHandlerClass disconnectHandler = new DisconnectHandlerClass(this); disconnectThread = new Thread(new Runnable() { @Override public void run() { int stop = 0; while (stop == 0) { stop = getDisconnect(); sleep(1500); } disconnectHandler.sendEmptyMessage(0); } }); disconnectThread.start(); } return true; case R.id.record_data: Log.d(TAG, "Record button was Pressed. Gps status: " + gpsStatus); if (!recording && gpsStatus) { Intent resetIntent = new Intent(); resetIntent.putExtra("reset", ""); resetIntent.setAction("resetFilter"); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(resetIntent); item.setIcon(R.drawable.ic_action_stop); Toast.makeText(getApplicationContext(), "Start recording data", Toast.LENGTH_LONG).show(); currentTime = System.currentTimeMillis(); recordClock.setVisibility(View.VISIBLE); Animation a = AnimationUtils.loadAnimation(this, R.anim.textslide); TextView tv = (TextView) findViewById(R.id.recordClock); tv.startAnimation(a); recording = true; if (!rBound) { Intent intent = new Intent(this, RecordService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } } else if (recording) { stopRecording(); } return true; case R.id.vr_menu: if (!recording) { Intent vrIntent = new Intent(Main.this, VRmenuMap.class); Main.this.startActivity(vrIntent); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.aegiswallet.actions.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); application = (PayBitsApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); smsTxnsPrefs = application.getSharedPreferences(getString(R.string.sms_transaction_filename), Context.MODE_PRIVATE); //smsTxnsPrefs.edit().clear().commit(); wallet = application.getWallet();/*from w w w . j a va2 s. c o m*/ application.initializeShamirSecretSharing(context); checkIfAppInitiated(); setContentView(R.layout.activity_main); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getActionBar().setCustomView(R.layout.aegis_actionbar); openDrawerButton = (ImageButton) findViewById(R.id.action_bar_icon); openDrawerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mDrawerLayout != null) { if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) mDrawerLayout.closeDrawer(Gravity.LEFT); else mDrawerLayout.openDrawer(Gravity.LEFT); } } }); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); blockchainStatus = (TextView) findViewById(R.id.blockchain_status); blockchainStatus.setTypeface(BasicUtils.getCustomTypeFace(getBaseContext())); setupBlockchainBroadcastReceiver(blockchainStatus); GetCurrencyInfoTask currencyInfoTask = new GetCurrencyInfoTask(getApplicationContext()); currencyInfoTask.execute(); //currencyInfoTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); watchedBalanceLinearLayout = (LinearLayout) findViewById(R.id.watched_balance_view); walletBalanceView = (TextView) findViewById(R.id.wallet_balance); walletBalanceView.setTypeface(BasicUtils.getCustomTypeFace(getBaseContext())); if (!prefs.contains(Constants.CURRENCY_PREF_KEY)) { prefs.edit().putString(Constants.CURRENCY_PREF_KEY, "USD").commit(); } walletWatchAddressBalanceView = (TextView) findViewById(R.id.watch_only_balance); updateMainViews(); determineSelectedAddress(); application.startBlockchainService(false); handleButtons(); recentTransactions = (ArrayList<Transaction>) wallet.getRecentTransactions(50, true); transactionListAdapter = new TransactionListAdapter(this, R.layout.transaction_detail_row, recentTransactions, wallet); transactionListView = (ListView) findViewById(R.id.transaction_list); if (recentTransactions == null || recentTransactions.size() == 0) transactionListView.setEmptyView(findViewById(R.id.transaction_empty_view_main)); transactionListView.setAdapter(transactionListAdapter); handlePendingTransactions(); initiateHandlers(walletBalanceView); application.addWalletListener(balanceHandler); checkWalletEncryptionStatus(); this.registerReceiver(receiver, new IntentFilter(PeerBlockchainService.ACTION_BLOCKCHAIN_STATE)); doDrawerSetup(); String message = getIntent().getStringExtra("message"); if (message != null) { Toast.makeText(context, message, Toast.LENGTH_LONG).show(); getIntent().removeExtra("message"); } nfcEnabled = prefs.contains(Constants.SHAMIR_ENCRYPTED_KEY) ? false : true; checkBackupDone(); doBackupReminder(); isServiceBound = this.bindService(new Intent(this, PeerBlockchainService.class), blockchainServiceConnection, Context.BIND_AUTO_CREATE); HandleSMSResponsesTask handleSMSResponsesTask = new HandleSMSResponsesTask(this); //handleSMSResponsesTask.execute(); handleSMSResponsesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); sendMessagesToWear(); }
From source file:com.synox.android.authentication.AuthenticatorActivity.java
/** * {@inheritDoc}/*from w w w. jav a 2 s . co 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); // Workaround, for fixing a problem with Android Library Suppor v7 19 //getWindow().requestFeature(Window.FEATURE_NO_TITLE); if (getSupportActionBar() != null) { getSupportActionBar().hide(); getSupportActionBar().setDisplayHomeAsUpEnabled(false); getSupportActionBar().setDisplayShowHomeEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(false); } mIsFirstAuthAttempt = true; // 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); mIsFirstAuthAttempt = savedInstanceState.getBoolean(KEY_AUTH_IS_FIRST_ATTEMPT_TAG); } /// load user interface setContentView(R.layout.account_setup); /// initialize general UI elements initOverallUi(); mOkButton = findViewById(R.id.buttonOK); mOkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onOkClick(); } }); View mCenteredRefreshButton = findViewById(R.id.centeredRefreshButton); mCenteredRefreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkOcServer(); } }); 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"); }