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.jtxdriggers.android.ventriloid.Connected.java
@Override public void onStart() { super.onStart(); if (!VentriloidService.isConnected()) { startActivity(new Intent(this, Main.class)); finish();/* w ww. jav a 2s . com*/ } else { bindService(new Intent(VentriloidService.SERVICE_INTENT), serviceConnection, Context.BIND_AUTO_CREATE); registerReceiver(serviceReceiver, new IntentFilter(SERVICE_RECEIVER)); registerReceiver(fragmentReceiver, new IntentFilter(FRAGMENT_RECEIVER)); } }
From source file:edu.asu.cse535.assignment3.MainActivity.java
public void onStartRecordingWalking(View v) { Log.w(this.getClass().getSimpleName(), "Button is clicked"); intent = new Intent(MainActivity.this.getBaseContext(), AccIntentService.class); intent.putExtra("activity", Constants.ACTIVITY_WALKING); startService(intent);// w w w . j a v a 2 s . com 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:de.gruenewald.udacity.spotifystreamer.PlaybackFragment.java
@Override public void onStart() { super.onStart(); if (mPlaybackIntent == null) { mPlaybackIntent = new Intent(getActivity(), PlaybackService.class); }/*from ww w .j a v a2s. c o m*/ if (!mBound) { getActivity().bindService(mPlaybackIntent, mPlaybackServiceConnection, Context.BIND_AUTO_CREATE); } }
From source file:com.owncloud.android.ui.activity.ManageAccountsActivity.java
/** * Initialize ComponentsGetters.//w w w . ja va 2 s .c o m */ private void initializeComponentGetters() { 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:au.org.ala.fielddata.mobile.CollectSurveyData.java
public void startLocationUpdates() { if (locationServiceConnection == null) { locationServiceConnection = new LocationServiceConnection(this, getRequiredLocationAccuracy()); Intent intent = new Intent(this, LocationServiceHelper.class); bindService(intent, locationServiceConnection, Context.BIND_AUTO_CREATE); }/*from w w w . j a v a 2 s. c o m*/ if (scheduler == null) { scheduler = Executors.newScheduledThreadPool(1); } timer = scheduler.schedule(new Runnable() { public void run() { cancelLocationUpdates(); } }, GPS_TIMEOUT, TimeUnit.SECONDS); gpsTrackingOn = true; }
From source file:com.example.scandevice.ScanDevice.java
/** * Bind the activity to a background service and put them into foreground * state./*from ww w . ja v a 2 s. com*/ */ private void startService() { context = cordova.getActivity(); Intent wifiIntent = new Intent(context, WifiScanService.class); wifiIntent.putExtra(WifiScanService.TIME_STAMP, interval); Intent bluetooth = new Intent(context, BluetoothScanService.class); bluetooth.putExtra(BluetoothScanService.TIME_STAMP, interval); try { context.bindService(wifiIntent, connection, Context.BIND_AUTO_CREATE); context.startService(wifiIntent); context.bindService(bluetooth, connection2, Context.BIND_AUTO_CREATE); context.startService(bluetooth); } catch (Exception e) { e.printStackTrace(); } isBind = true; }
From source file:com.z3r0byte.magistify.DashboardActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); mToolbar = (Toolbar) findViewById(R.id.Toolbar); mToolbar.setTitle(R.string.title_dashboard); setSupportActionBar(mToolbar);/*from w w w .jav a2 s . c o m*/ configUtil = new ConfigUtil(this); User user = new Gson().fromJson(configUtil.getString("User"), User.class); Profile profile = new Gson().fromJson(configUtil.getString("Profile"), Profile.class); NavigationDrawer navigationDrawer = new NavigationDrawer(this, mToolbar, profile, user, "Dashboard"); navigationDrawer.SetupNavigationDrawer(); mSwipeRefreshLayout = (ScrollRefreshLayout) findViewById(R.id.layout_refresh); mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.setup_color_3, R.color.setup_color_5); mSwipeRefreshLayout.setSwipeableChildren(R.id.card_layout); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Log.d(TAG, "onRefresh: Refreshing!"); mSwipeRefreshLayout.setVisibility(View.GONE); mSwipeRefreshLayout.setVisibility(View.VISIBLE); setupAppointmentCard(); setupChangeCard(); retrieveGrades(); } }); if (!configUtil.getBoolean("disable_ads")) { MobileAds.initialize(getApplicationContext(), getString(R.string.app_ad_id)); AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().addTestDevice("BEF9819F219452AE8661484A2AA03C59").build(); mAdView.loadAd(adRequest); } else { findViewById(R.id.adView).setVisibility(View.GONE); } if (configUtil.getInteger("failed_auth") >= 2) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage(R.string.dialog_login_failed_desc); alertDialogBuilder.setPositiveButton(R.string.msg_relogin, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { relogin(); } }); alertDialogBuilder.setNegativeButton(R.string.msg_later, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); appointmentMain = (CardView) findViewById(R.id.card_next_appointment); scheduleChangeMain = (CardView) findViewById(R.id.card_schedulechanges); gradeMain = (CardView) findViewById(R.id.card_new_grade); gradeMain.setVisibility(View.GONE); setupAppointmentCard(); setupChangeCard(); retrieveGrades(); getPurchases(); showUpdateMessage(); }
From source file:io.teak.sdk.GooglePlay.java
public void init(Context context) { mContext = context;//from w w w. jav a 2s .co m mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Billing service disconnected."); } mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { if (mDisposed) return; if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Billing service connected."); } try { Class<?> cls = Class.forName("com.android.vending.billing.IInAppBillingService$Stub"); Method m = cls.getMethod("asInterface", IBinder.class); mService = m.invoke(null, (Object) service); } catch (Exception e) { Log.e(LOG_TAG, "Unable to use 'IInAppBillingService' via reflection. " + Log.getStackTraceString(e)); Teak.sdkRaven.reportException(e); return; } String packageName = mContext.getPackageName(); try { if (Teak.isDebug) { Log.d(LOG_TAG, "Checking for Google Play in-app billing 3 support."); } // check for in-app billing v3 support Class<?> cls = Class.forName("com.android.vending.billing.IInAppBillingService"); Method m = cls.getMethod("isBillingSupported", int.class, String.class, String.class); int response = (Integer) m.invoke(mService, 3, packageName, ITEM_TYPE_INAPP); if (response != BILLING_RESPONSE_RESULT_OK) { Log.e(LOG_TAG, "Error checking for Google Play billing v3 support."); } else { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play In-app billing version 3 supported for " + packageName); } } // Check for v5 subscriptions support. This is needed for // getBuyIntentToReplaceSku which allows for subscription update response = (Integer) m.invoke(mService, 5, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscription re-signup available."); Log.d(LOG_TAG, "Google Play Subscriptions available."); } } else { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscription re-signup not available."); } // check for v3 subscriptions support response = (Integer) m.invoke(mService, 3, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscriptions available."); } } else { if (Teak.isDebug) { Log.d(LOG_TAG, "Google Play Subscriptions NOT available. Response: " + response); } } } } catch (Exception e) { Log.e(LOG_TAG, "Error working with InAppBillingService: " + Log.getStackTraceString(e)); Teak.sdkRaven.reportException(e); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); List<ResolveInfo> intentServices = mContext.getPackageManager().queryIntentServices(serviceIntent, 0); if (intentServices != null && !intentServices.isEmpty()) { mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else { Log.e(LOG_TAG, "Google Play Billing service unavailable on device."); } }
From source file:fr.forexperts.ui.PortfolioFragment.java
@Override public void onStart() { super.onStart(); // Bind to Service Intent intent = new Intent(getActivity(), DataService.class); getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); SharedPreferences prefs = getActivity().getSharedPreferences("portfolio", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); Map<String, ?> values = prefs.getAll(); mData.clear();/*from w w w . java2 s .co m*/ portfolioListAdapter.notifyDataSetChanged(); if (values.size() == 0) { mProgressBar.setVisibility(View.GONE); mAddButton.setVisibility(View.VISIBLE); } else { mProgressBar.setVisibility(View.VISIBLE); String code = ""; for (Map.Entry<String, ?> entre : values.entrySet()) { code = code + entre.getValue() + ","; } code = code.substring(0, code.length() - 1); editor.clear(); editor.apply(); AddTickerTask task = new AddTickerTask(); task.execute(code); } }
From source file:com.csipsimple.ui.incall.CallActivity.java
@SuppressWarnings("deprecation") @Override// ww w .j av a 2 s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //handler.setActivityInstance(this); Log.i(TAG, "######## onCreate"); getWindow().requestFeature(Window.FEATURE_NO_TITLE); this.setFinishOnTouchOutside(false); setContentView(R.layout.call_dialog); targetName = getIntent().getStringExtra(SipManager.CALLEE_NAME_INTENT_KEY); if (targetName != null) { Log.i(TAG, "targetName: " + targetName); } SipCallSession initialSession = getIntent().getParcelableExtra(SipManager.EXTRA_CALL_INFO); synchronized (callMutex) { callsInfo = new SipCallSession[1]; callsInfo[0] = initialSession; } bindService(new Intent(this, SipService.class), connection, Context.BIND_AUTO_CREATE); prefsWrapper = new PreferencesProviderWrapper(this); // Log.d(TAG, "Creating call handler for " + // callInfo.getCallId()+" state "+callInfo.getRemoteContact()); powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "com.csipsimple.onIncomingCall"); wakeLock.setReferenceCounted(false); takeKeyEvents(true); // Cache findViews mainFrame = (ViewGroup) findViewById(R.id.mainFrame); //inCallControls = (InCallControls) findViewById(R.id.inCallControls); inCallAnswerControls = (InCallAnswerControls) findViewById(R.id.inCallAnswerControls); activeCallsGrid = (InCallInfoGrid) findViewById(R.id.activeCallsGrid); heldCallsGrid = (InCallInfoGrid) findViewById(R.id.heldCallsGrid); // Bind attachVideoPreview(); //inCallControls.setOnTriggerListener(this); inCallAnswerControls.setOnTriggerListener(this); if (activeCallsAdapter == null) { activeCallsAdapter = new CallsAdapter(true); } activeCallsGrid.setAdapter(activeCallsAdapter); if (heldCallsAdapter == null) { heldCallsAdapter = new CallsAdapter(false); } heldCallsGrid.setAdapter(heldCallsAdapter); ScreenLocker lockOverlay = (ScreenLocker) findViewById(R.id.lockerOverlay); lockOverlay.setActivity(this); lockOverlay.setOnLeftRightListener(this); /* middleAddCall = (Button) findViewById(R.id.add_call_button); middleAddCall.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { onTrigger(ADD_CALL, null); } }); if (!prefsWrapper.getPreferenceBooleanValue(SipConfigManager.SUPPORT_MULTIPLE_CALLS)) { middleAddCall.setEnabled(false); middleAddCall.setText(R.string.not_configured_multiple_calls); } */ // Listen to media & sip events to update the UI registerReceiver(callStateReceiver, new IntentFilter(SipManager.ACTION_SIP_CALL_CHANGED)); registerReceiver(callStateReceiver, new IntentFilter(SipManager.ACTION_SIP_MEDIA_CHANGED)); registerReceiver(callStateReceiver, new IntentFilter(SipManager.ACTION_ZRTP_SHOW_SAS)); proximityManager = new CallProximityManager(this, this, lockOverlay); keyguardManager = KeyguardWrapper.getKeyguardManager(this); dialFeedback = new DialingFeedback(this, true); if (prefsWrapper.getPreferenceBooleanValue(SipConfigManager.PREVENT_SCREEN_ROTATION)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } if (quitTimer == null) { quitTimer = new Timer("Quit-timer"); } useAutoDetectSpeaker = prefsWrapper.getPreferenceBooleanValue(SipConfigManager.AUTO_DETECT_SPEAKER); applyTheme(); proximityManager.startTracking(); //inCallControls.setCallState(initialSession); inCallAnswerControls.setCallState(initialSession); }