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.coinblesk.client.CurrentBalanceFragment.java
@Override public void onStart() { super.onStart(); Intent intent = new Intent(getActivity(), WalletService.class); getActivity().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); LocalBroadcastManager broadcaster = LocalBroadcastManager.getInstance(getActivity()); IntentFilter balanceFilter = new IntentFilter(Constants.WALLET_BALANCE_CHANGED_ACTION); balanceFilter.addAction(Constants.EXCHANGE_RATE_CHANGED_ACTION); broadcaster.registerReceiver(walletBalanceChangeBroadcastReceiver, balanceFilter); broadcaster.registerReceiver(exchangeRateChangeListener, new IntentFilter(Constants.EXCHANGE_RATE_CHANGED_ACTION)); IntentFilter walletProgressFilter = new IntentFilter(Constants.WALLET_DOWNLOAD_PROGRESS_ACTION); walletProgressFilter.addAction(Constants.WALLET_DOWNLOAD_DONE_ACTION); broadcaster.registerReceiver(walletProgressBroadcastReceiver, walletProgressFilter); IntentFilter filter = new IntentFilter(); filter.addAction(Constants.WALLET_CHANGED_ACTION); filter.addAction(Constants.WALLET_DOWNLOAD_DONE_ACTION); broadcaster.registerReceiver(walletChangedBroadcastReceiver, filter); }
From source file:fi.tuukka.weather.view.ActivityMain.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity);//from w ww . jav a 2s. c om pagerAdapter = new WeatherFragmentPagerAdapter(getSupportFragmentManager()); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setCurrentItem(FIRSTTAB.ordinal()); bindService(new Intent(this, Downloader.class), downloaderConnection, Context.BIND_AUTO_CREATE); }
From source file:com.commonsware.android.advservice.remotebinding.sigcheck.DownloadFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true);// w w w . j av a2 s . co m appContext = (Application) getActivity().getApplicationContext(); Intent implicit = new Intent(IDownload.class.getName()); List<ResolveInfo> matches = getActivity().getPackageManager().queryIntentServices(implicit, 0); if (matches.size() == 0) { Toast.makeText(getActivity(), "Cannot find a matching service!", Toast.LENGTH_LONG).show(); } else if (matches.size() > 1) { Toast.makeText(getActivity(), "Found multiple matching services!", Toast.LENGTH_LONG).show(); } else { ServiceInfo svcInfo = matches.get(0).serviceInfo; try { String otherHash = SignatureUtils.getSignatureHash(getActivity(), svcInfo.applicationInfo.packageName); String expected = getActivity().getString(R.string.expected_sig_hash); if (expected.equals(otherHash)) { Intent explicit = new Intent(implicit); ComponentName cn = new ComponentName(svcInfo.applicationInfo.packageName, svcInfo.name); explicit.setComponent(cn); appContext.bindService(explicit, this, Context.BIND_AUTO_CREATE); } else { Toast.makeText(getActivity(), "Unexpected signature found!", Toast.LENGTH_LONG).show(); } } catch (Exception e) { Log.e(getClass().getSimpleName(), "Exception trying to get signature hash", e); } } }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
@Override public void onCreate() { Intent intForBleepService = new Intent(this, BLEepService.class); bindService(intForBleepService, bleepConnection, Context.BIND_AUTO_CREATE); }
From source file:com.android.madpausa.cardnotificationviewer.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (sp.getBoolean(SettingsActivityFragment.TEST_MODE, false)) setContentView(R.layout.activity_main_test); else/*w ww .j av a 2 s .com*/ setContentView(R.layout.activity_main); //binding the service Intent intent = new Intent(this, ConcreteNotificationListenerService.class); intent.setAction(ConcreteNotificationListenerService.CUSTOM_BINDING); bindService(intent, nConnection, Context.BIND_AUTO_CREATE); nReceiver = new NotificationReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(ConcreteNotificationListenerService.ADD_NOTIFICATION_ACTION); filter.addAction(ConcreteNotificationListenerService.REMOVE_NOTIFICATION_ACTION); filter.addAction(NotificationDialogFragment.NOTIFICATION_DIALOG_INTENT); LocalBroadcastManager.getInstance(this).registerReceiver(nReceiver, filter); nFragment = (MainActivityFragment) getSupportFragmentManager().findFragmentById(R.id.fragment); }
From source file:com.gigathinking.simpleapplock.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_main); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mServiceConn = new ServiceConnection() { @Override/*w ww . j a v a2 s .c o m*/ public void onServiceConnected(ComponentName name, IBinder service) { mService = IInAppBillingService.Stub.asInterface(service); new CheckPurchases().execute(); } @Override public void onServiceDisconnected(ComponentName name) { mService = null; } }; bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn, Context.BIND_AUTO_CREATE); if (mPrefs.getString("welcome_shown", null) == null) { startActivity(new Intent(this, Welcome.class)); } mAppListData = new AppListData(this); mAppListData.init(); if (!mPrefs.getBoolean(getString(R.string.register_complete), false)) { new Register().execute(); } mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); if (savedInstanceState != null) { return; } if (mPrefs.getBoolean(AppLockApplication.LOCKSET, false)) { if (mPrefs.getString(AppLockApplication.LOCKTYPE, "").equals(AppLockApplication.LOCKTYPE_PIN)) { startActivityForResult( new Intent(this, UnlockWithPIN.class).putExtra(AppLockApplication.UNLOCK_SELF, true), 23); } if (mPrefs.getString(AppLockApplication.LOCKTYPE, "").equals(AppLockApplication.LOCKTYPE_GESTURE)) { startActivityForResult( new Intent(this, UnlockWithGesture.class).putExtra(AppLockApplication.UNLOCK_SELF, true), 23); } if (mPrefs.getString(AppLockApplication.LOCKTYPE, "").equals(AppLockApplication.LOCKTYPE_PATTERN)) { Intent intent = new Intent(LockPatternActivity.ACTION_COMPARE_PATTERN, null, this, LockPatternActivity.class); intent.putExtra(LockPatternActivity.EXTRA_PATTERN, Settings.Security.getPattern(this)); intent.putExtra(LockPatternActivity.EXTRA_INTENT_ACTIVITY_FORGOT_PATTERN, new Intent(this, ResetUnlockMethod.class)); startActivityForResult(intent, 23); } } Intent intent = new Intent(this, AppLaunchDetectorService.class); startService(intent); }
From source file:com.subzero.runners.android.AndroidLauncher.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create the GameHelper _gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES); _gameHelper.enableDebugLog(false);/* w w w. j av a2 s.c o m*/ GameHelperListener gameHelperListener = new GameHelper.GameHelperListener() { @Override public void onSignInSucceeded() { // TODO Auto-generated method stub } @Override public void onSignInFailed() { // TODO Auto-generated method stub } }; _gameHelper.setup(gameHelperListener); // signIn(); Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); // queryPurchases(); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); config.useImmersiveMode = true; initialize(new Runners(this), config); }
From source file:com.superdrive.plugins.LockScreenManager.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { callbackCtx = callbackContext;/*w ww .j a va 2 s . c o m*/ try { if (ACTION_ENABLE_SCREEN_LOCK.equals(action)) { if (isServiceStarted) { globalService.LockScreen(); } callbackCtx.success(); return true; } if (ACTION_DISABLE_SCREEN_LOCK.equals(action)) { if (isServiceStarted) { globalService.UnlockScreen(); } callbackContext.success(); return true; } if (ACTION_START_SERVICE.equals(action)) { if (!isServiceStarted) { Intent intent = new Intent(cordova.getActivity(), GlobalService.class); cordova.getActivity().bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); cordova.getActivity().startService(intent); isServiceStarted = true; } callbackCtx.success(); return true; } if (ACTION_STOP_SERVICE.equals(action)) { if (isServiceStarted) { Intent intent = new Intent(cordova.getActivity(), GlobalService.class); cordova.getActivity().unbindService(serviceConnection); cordova.getActivity().stopService(intent); isServiceStarted = false; } callbackCtx.success(); return true; } callbackContext.error("Invalid action"); return false; } catch (Exception e) { callbackContext.error(e.getMessage()); return false; } }
From source file:de.petendi.ethereum.android.EthereumAndroid.java
public EthereumAndroid(Context context, EthereumAndroidCallback callback) { this.context = context; this.callback = callback; objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); EthereumAndroidService.responseHandler = new CallbackHandler(); packageName = context.getApplicationInfo().packageName; Intent intent = new Intent("de.petendi.ethereum.android.action.BIND_API"); intent.setPackage(EthereumAndroidFactory.PACKAGENAME); serviceConnection = new ServiceConnection() { @Override// w w w .j a v a 2 s . c o m public void onServiceConnected(ComponentName componentName, IBinder iBinder) { binder = IEthereumService.Stub.asInterface(iBinder); } @Override public void onServiceDisconnected(ComponentName componentName) { binder = null; } }; context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.kevelbreh.steamchat.activity.AuthenticationActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_login_2); ButterKnife.inject(this); bindService(new Intent(this, SteamService.class), mConnection, Context.BIND_AUTO_CREATE); mAuthenticate.setOnClickListener(new View.OnClickListener() { @Override/*w w w . j av a2 s. c o m*/ public void onClick(View view) { authenticate(); } }); }