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.soomla.store.billing.nokia.NokiaIabHelper.java
/** * See parent/*ww w .j a va 2s .c o m*/ */ protected void startSetupInner() { SoomlaUtils.LogDebug(TAG, "startSetupInner launched"); mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { SoomlaUtils.LogDebug(TAG, "Billing service disconnected."); mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { SoomlaUtils.LogDebug(TAG, "Billing service connected."); mService = INokiaIAPService.Stub.asInterface(service); String packageName = SoomlaApp.getAppContext().getPackageName(); try { SoomlaUtils.LogDebug(TAG, "Checking for in-app billing 3 support."); // check for in-app billing v3 support int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP); if (response != IabResult.BILLING_RESPONSE_RESULT_OK) { setupFailed(new IabResult(response, "Error checking for billing v3 support.")); return; } SoomlaUtils.LogDebug(TAG, "In-app billing version 3 supported for " + packageName); setupSuccess(); } catch (RemoteException e) { setupFailed(new IabResult(IabResult.IABHELPER_REMOTE_EXCEPTION, "RemoteException while setting up in-app billing.")); e.printStackTrace(); } } }; SoomlaApp.getAppContext().bindService(new Intent("com.nokia.payment.iapenabler.InAppBillingService.BIND"), mServiceConn, Context.BIND_AUTO_CREATE); }
From source file:com.android.car.trust.CarBleTrustAgent.java
@Override public void onCreate() { super.onCreate(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Bluetooth trust agent starting up"); }//from ww w. j a v a 2s . com IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_REVOKE_TRUST); filter.addAction(ACTION_ADD_TOKEN); filter.addAction(ACTION_IS_TOKEN_ACTIVE); filter.addAction(ACTION_REMOVE_TOKEN); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this /* context */); mLocalBroadcastManager.registerReceiver(mTrustEventReceiver, filter); // If the user is already unlocked, don't bother starting the BLE service. UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); if (!um.isUserUnlocked()) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "User locked, will now bind CarUnlockService"); } Intent intent = new Intent(this, CarUnlockService.class); bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); } else { setManagingTrust(true); } }
From source file:com.yangtsaosoftware.pebblemessenger.services.MessageProcessingService.java
@Override public void onCreate() { super.onCreate(); phone_is_ontalking = false;// w ww .j a v a 2 s .c o m loadPrefs(); Thread proceedthread = new ProcessThread(); proceedthread.start(); messageHandler = new MessageHandler(Looper.getMainLooper()); mMessenger = new Messenger(messageHandler); MessageProcessingService._context = getApplicationContext(); fdb = new FontDbHandler(_context); fdb.open(); mdb = new MessageDbHandler(_context); mdb.open(); bindService(new Intent(this, PebbleCenter.class), connToPebbleCenter, Context.BIND_AUTO_CREATE); BroadcastReceiver br = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int command = intent.getIntExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PREFER_CHANGED); switch (command) { case Constants.BROADCAST_PREFER_CHANGED: loadPrefs(); break; case Constants.BROADCAST_CALL_INCOMING: String number = intent.getStringExtra(Constants.BROADCAST_PHONE_NUM); String name = intent.getStringExtra(Constants.BROADCAST_NAME); if (callQuietEnable) { Calendar c = Calendar.getInstance(); Calendar now = new GregorianCalendar(0, 0, 0, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); Constants.log(TAG_NAME, "Checking quiet hours. Now: " + now.toString() + " vs " + quiet_hours_before.toString() + " and " + quiet_hours_after.toString()); if (now.before(quiet_hours_before) || now.after(quiet_hours_after)) { Constants.log(TAG_NAME, "Time is before or after the quiet hours time. Returning."); addNewCall(number, name, MessageDbHandler.NEW_ICON); } else { Bundle b = new Bundle(); b.putLong(MessageDbHandler.COL_CALL_ID, addNewCall(number, name, MessageDbHandler.OLD_ICON)); b.putString(MessageDbHandler.COL_CALL_NUMBER, number); b.putString(MessageDbHandler.COL_CALL_NAME, name); Message innerMsg = processHandler.obtainMessage(INNER_CALL_PROCEED); innerMsg.setData(b); processHandler.sendMessage(innerMsg); } } else { Bundle b = new Bundle(); if (phone_is_ontalking) { b.putString(MessageDbHandler.COL_MESSAGE_APP, "Call"); b.putString(MessageDbHandler.COL_MESSAGE_CONTENT, name + "\n" + number); addNewCall(number, name, MessageDbHandler.NEW_ICON); b.putLong(MessageDbHandler.COL_MESSAGE_ID, addNewMessage(b, MessageDbHandler.OLD_ICON)); Message innerMsg = processHandler.obtainMessage(INNER_MESSAGE_PROCEED); innerMsg.setData(b); processHandler.sendMessage(innerMsg); } else { b.putLong(MessageDbHandler.COL_CALL_ID, addNewCall(number, name, MessageDbHandler.OLD_ICON)); b.putString(MessageDbHandler.COL_CALL_NUMBER, number); b.putString(MessageDbHandler.COL_CALL_NAME, name); Message innerMsg = processHandler.obtainMessage(INNER_CALL_PROCEED); innerMsg.setData(b); processHandler.sendMessage(innerMsg); } } break; case Constants.BROADCAST_CALL_HOOK: phone_is_ontalking = true; break; case Constants.BROADCAST_CALL_IDLE: phone_is_ontalking = false; break; case Constants.BROADCAST_SMS_INCOMING: { Message msg = Message.obtain(); msg.what = MSG_NEW_MESSAGE; Bundle b = new Bundle(); b.putString(MessageDbHandler.COL_MESSAGE_APP, "SMS"); b.putString(MessageDbHandler.COL_MESSAGE_CONTENT, intent.getStringExtra(Constants.BROADCAST_SMS_BODY)); msg.setData(b); messageHandler.sendMessage(msg); } } } }; IntentFilter intentFilter = new IntentFilter(MessageProcessingService.class.getName()); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(br, intentFilter); }
From source file:com.secupwn.aimsicd.ui.fragments.CellInfoFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mContext = getActivity().getBaseContext(); // Bind to LocalService Intent intent = new Intent(mContext, AimsicdService.class); mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); swipeRefreshLayout.setOnRefreshListener(this); }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.transformationmanager.TransformationManager.java
@Override public void onCreate() { if (D)//from w w w .ja v a 2s .com Log.i(TAG, "TransformationManager created."); // start Felix OSGi service Intent intent = new Intent(this, FelixService.class); bindService(intent, felixServiceConnection, Context.BIND_AUTO_CREATE); // register local management receiver mManagementReceiver = new ManagementReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(mManagementReceiver, new IntentFilter(AbstractChannel.LOCAL_MANAGEMENT)); LocalBroadcastManager.getInstance(this).registerReceiver(mManagementReceiver, new IntentFilter(WEB_REQUEST_CHANNEL)); // register transformation download receiver mDownloadReceiver = new TransformationDownloadReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(mDownloadReceiver, new IntentFilter(TM_SUCCUESSFUL_WEB_REQUEST)); // initialize database this.transformationDB = new LocalTransformationDBMS(getApplicationContext()); //TODO better solution transformationDB.open(); availableTransformations = transformationDB.getAvailableTransformations(); if (D) printLocalTransformations(); // initialize management lists providedEventTypes = new HashMap<String, List<Transformation>>(); requiredEventTypes = new HashMap<String, List<Transformation>>(); runningTransformations = new LinkedList<Transformation>(); }
From source file:src.com.nustats.pacelogger.RecordingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.recording);//from w w w . j a v a 2 s.c om txtStat = (TextView) findViewById(R.id.TextRecordStats); txtDistance = (TextView) findViewById(R.id.TextDistance); txtDuration = (TextView) findViewById(R.id.TextDuration); txtCurSpeed = (TextView) findViewById(R.id.TextSpeed); txtMaxSpeed = (TextView) findViewById(R.id.TextMaxSpeed); txtAvgSpeed = (TextView) findViewById(R.id.TextAvgSpeed); pauseButton = (Button) findViewById(R.id.ButtonPause); finishButton = (Button) findViewById(R.id.ButtonFinished); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); // Query the RecordingService to figure out what to do. Intent rService = new Intent(this, RecordingService.class); startService(rService); ServiceConnection sc = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { } public void onServiceConnected(ComponentName name, IBinder service) { IRecordService rs = (IRecordService) service; switch (rs.getState()) { // If recording service is idle, start recording case RecordingService.STATE_IDLE: trip = TripData.createTrip(RecordingActivity.this); rs.startRecording(trip); isRecording = true; RecordingActivity.this.pauseButton.setEnabled(true); RecordingActivity.this.setTitle("PaceLogger - Recording..."); break; // If recording service is recording, fetch data case RecordingService.STATE_RECORDING: long id = rs.getCurrentTrip(); trip = TripData.fetchTrip(RecordingActivity.this, id); isRecording = true; RecordingActivity.this.pauseButton.setEnabled(true); RecordingActivity.this.setTitle("PaceLogger - Recording..."); break; // If recording service is paused, fetch data, display resume option case RecordingService.STATE_PAUSED: long tid = rs.getCurrentTrip(); isRecording = false; trip = TripData.fetchTrip(RecordingActivity.this, tid); RecordingActivity.this.pauseButton.setEnabled(true); RecordingActivity.this.pauseButton.setText("Resume"); RecordingActivity.this.setTitle("PaceLogger - Paused..."); break; case RecordingService.STATE_FULL: // Should never get here, right? break; } rs.setListener(RecordingActivity.this); unbindService(this); } }; bindService(rService, sc, Context.BIND_AUTO_CREATE); // Pause button pauseButton.setEnabled(false); pauseButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { isRecording = !isRecording; if (isRecording) { pauseButton.setText("Pause"); RecordingActivity.this.setTitle("PaceLogger - Recording..."); // Don't include pause time in trip duration if (trip.pauseStartedAt > 0) { trip.totalPauseTime += (System.currentTimeMillis() - trip.pauseStartedAt); trip.pauseStartedAt = 0; } Toast.makeText(getBaseContext(), "GPS restarted. It may take a moment to resync.", Toast.LENGTH_LONG).show(); } else { pauseButton.setText("Resume"); RecordingActivity.this.setTitle("PaceLogger - Paused..."); trip.pauseStartedAt = System.currentTimeMillis(); Toast.makeText(getBaseContext(), "Recording paused; GPS now offline", Toast.LENGTH_LONG).show(); } RecordingActivity.this.setListener(); } }); // Finish button finishButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // If we have points, go to the save-trip activity if (trip.numpoints > 0) { // Handle pause time gracefully if (trip.pauseStartedAt > 0) { trip.totalPauseTime += (System.currentTimeMillis() - trip.pauseStartedAt); } if (trip.totalPauseTime > 0) { trip.endTime = System.currentTimeMillis() - trip.totalPauseTime; } // Save trip so far (points and extent, but no purpose or notes) fi = new Intent(RecordingActivity.this, SaveTrip.class); trip.updateTrip("", "", "", ""); } // Otherwise, cancel and go back to main screen else { Toast.makeText(getBaseContext(), "No GPS data acquired; nothing to submit.", Toast.LENGTH_SHORT) .show(); cancelRecording(); // Go back to main screen fi = new Intent(RecordingActivity.this, MainInput.class); fi.putExtra("keep", true); } // Either way, activate next task, and then kill this task startActivity(fi); RecordingActivity.this.finish(); } }); }
From source file:com.SecUpwN.AIMSICD.fragments.MapFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); log.info("Starting MapViewer"); setUpMapIfNeeded();// w w w . j a v a 2s.co m mDbHelper = new AIMSICDDbAdapter(getActivity()); tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); // Bind to LocalService Intent intent = new Intent(getActivity(), AimsicdService.class); getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); }
From source file:com.secupwn.aimsicd.ui.activities.MapViewerOsmDroid.java
/** * Called when the activity is first created. *///w w w . j av a2s . c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); log.info("Starting MapViewer"); setUpMapIfNeeded(); mDbHelper = new RealmHelper(this); tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); // Bind to LocalService Intent intent = new Intent(this, AimsicdService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); }
From source file:fr.mixit.android.ui.fragments.BoundServiceDialogFragment.java
protected void doBindService() { if (DEBUG_MODE) { Log.d(TAG, "doBindService()"); }/*from w ww . ja v a 2 s . c o m*/ // Establish a connection with the mService. We use an explicit class name because there is no reason to be able to let other applications replace our // component. if (getActivity() == null || isDetached()) { if (DEBUG_MODE) { Log.d(TAG, "Fragment is detached from hos activity or getActivity is null, so impossible to bind service"); } return; } getActivity().bindService(new Intent(getActivity(), MixItService.class), mConnection, Context.BIND_AUTO_CREATE); mIsBound = true; }
From source file:com.otaupdater.OTAUpdaterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getApplicationContext(); cfg = Config.getInstance(context);// w w w. j a v a 2s . co m if (!cfg.hasProKey()) { bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), billingSrvConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { billingSrvConn = null; } @Override public void onServiceConnected(ComponentName name, IBinder binder) { IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder); try { Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null); ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); ArrayList<String> ownedItemData = owned .getStringArrayList("INAPP_PURCHASE_DATA_LIST"); if (ownedItems != null && ownedItemData != null) { for (int q = 0; q < ownedItems.size(); q++) { if (ownedItems.get(q).equals(Config.PROKEY_SKU)) { JSONObject itemData = new JSONObject(ownedItemData.get(q)); cfg.setKeyPurchaseToken(itemData.getString("purchaseToken")); break; } } } } catch (RemoteException ignored) { } catch (JSONException e) { e.printStackTrace(); } unbindService(this); billingSrvConn = null; } }, Context.BIND_AUTO_CREATE); } boolean data = Utils.dataAvailable(this); boolean wifi = Utils.wifiConnected(this); if (!data || !wifi) { final boolean nodata = !data && !wifi; if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title); builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivity(i); } }); builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (nodata) { cfg.setIgnoredDataWarn(true); } else { cfg.setIgnoredWifiWarn(true); } dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } } Utils.updateDeviceRegistration(this); CheckinReceiver.setDailyAlarm(this); if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_unsupported_title); builder.setMessage(R.string.alert_unsupported_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { cfg.setIgnoredUnsupportedWarn(true); dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } setContentView(R.layout.main); Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads); if (adFragment != null) getFragmentManager().beginTransaction().hide(adFragment).commit(); ViewPager mViewPager = (ViewPager) findViewById(R.id.pager); bar = getActionBar(); assert bar != null; bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setTitle(R.string.app_name); TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class); ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom); if (cfg.hasStoredRomUpdate()) romTab.setIcon(R.drawable.ic_action_warning); romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class); ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel); if (cfg.hasStoredKernelUpdate()) kernelTab.setIcon(R.drawable.ic_action_warning); kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class); if (!handleNotifAction(getIntent())) { if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) { cfg.getStoredRomUpdate().showUpdateNotif(this); } if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) { cfg.getStoredKernelUpdate().showUpdateNotif(this); } if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0)); } } }