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.clover.android.sdk.examples.InventoryTestActivity.java
private void connectToInventoryService() { serviceConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { inventoryService = IInventoryService.Stub.asInterface(service); serviceIsBound = true;// w w w.j av a 2 s.com statusText.setText("connected to AIDL service"); fetchItemsFromService(); createObjectsUsingService(); } public void onServiceDisconnected(ComponentName className) { statusText.setText("disconnected from AIDL service"); inventoryService = null; serviceIsBound = false; } }; Account account = CloverAccount.getAccount(this); Intent intent = new Intent(InventoryIntent.ACTION_INVENTORY_SERVICE_V3); intent.putExtra(Intents.EXTRA_ACCOUNT, account); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.cerema.cloud2.authentication.AuthenticatorActivity.java
/** * {@inheritDoc}//from www . j a va 2s.c o 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(); } }); findViewById(R.id.centeredRefreshButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkOcServer(); } }); findViewById(R.id.embeddedRefreshButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkOcServer(); } }); /// 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"); }
From source file:com.dsna.android.main.MainActivity.java
@Override protected void onResume() { super.onResume(); Intent intent = new Intent(this, AndroidSocialService.class); intent.putExtra(bIp, mBootIp);//from ww w.ja va 2 s.c o m intent.putExtra(bPort, mBootPort); intent.putExtra(biPort, mBindPort); intent.putExtra(uName, mUsername); LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(AndroidSocialService.RECEIVE_ENTITY); intentFilter.addAction(AndroidSocialService.DISPLAY_TOAST); bManager.registerReceiver(bReceiver, intentFilter); System.out.println("Prepare to bind service"); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.SwitcherListFragment.java
/** * {@inheritDoc}/* ww w. ja va 2 s. c o m*/ */ @Override public void onStart() { super.onStart(); // Start and bind to the service Intent intent = new Intent(getActivity(), SwitcherService.class); getActivity().bindService(intent, this, Context.BIND_AUTO_CREATE); getActivity().startService(intent); // Permissions if (PermissionUtils.supportsRuntimePermissions()) { if (mIsInitialStart) { requestPermissions(); } else if (mHavePermissionsResult) { if (PermissionUtils.hasPermissions(getActivity(), PermissionUtils.STORAGE_PERMISSIONS)) { onPermissionsGranted(); } else { onPermissionsDenied(); } } } else { startWhenServiceConnected(); } }
From source file:com.mk4droid.IMC_Activities.Fragment_Map.java
/** * /*from w ww.j a v a 2 s . c o m*/ * On Resume * */ @Override public void onResume() { super.onResume(); //------------ Create Items on Maps ----------------------- if (fmap_main == null) { fmap_main = SupportMapFragment.newInstance(); FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction(); fragmentTransaction.add(R.id.flmain, fmap_main); fragmentTransaction.commit(); getChildFragmentManager().executePendingTransactions(); } if (fmap_main != null) gmap = fmap_main.getMap(); if (gmap != null) { gmap.setInfoWindowAdapter(new InfoWindowAdapterButtoned(getActivity())); gmap.setMyLocationEnabled(true); gmap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(Service_Location.locUserPred.getLatitude(), Service_Location.locUserPred.getLongitude()), 14)); } pbgeneral.bringToFront(); //------- Button Maps Types ------------ btMaps = (ImageButton) vframelayout_main.findViewById(R.id.btMapChange); btRefresh = (ImageButton) vframelayout_main.findViewById(R.id.btRefresh); btMyIss = (ImageButton) vframelayout_main.findViewById(R.id.btFilterMineIssMap); btRefresh.bringToFront(); btRefresh.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //---- Show dialog Refresh ---------- // dialogRefresh = ProgressDialog.show(ctx, resources.getString(R.string.Downloading), // resources.getString(R.string.Refresh), true); // ------- Broadcast Refresh through a handler Message msg = new Message(); msg.arg1 = 1; handlerBroadcastRefresh.sendMessage(msg); } }); //------ set Handlers and Receivers ------ HandlersAndReceivers(); //------------------------------------------------------------ btMaps.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //------------- Other maps views click -------- String bt_Tag = btMaps.getTag().toString(); if (bt_Tag.equals("Satellite")) { gmap.setMapType(MAP_TYPE_NORMAL); //btMaps.setText(resources.getString(R.string.NormalMap)); btMaps.setTag("Normal"); } else if (bt_Tag.equals("Normal")) { gmap.setMapType(MAP_TYPE_HYBRID); //btMaps.setText(resources.getString(R.string.Satellite)); btMaps.setTag("Satellite"); } } }); btMaps.bringToFront(); //-------------------------------------------------------------- resources = SetResources(); // to get new UserID if (!isLocServBound) ctx.bindService(IntLocServ, mLocConnection, Context.BIND_AUTO_CREATE); //---------- Maps ------------ String bt_Tag = btMaps.getTag().toString(); if (bt_Tag.equals("Normal") && gmap != null) { gmap.setMapType(MAP_TYPE_NORMAL); btMaps.setTag("Normal"); } else if (bt_Tag.equals("Satellite") && gmap != null) { gmap.setMapType(MAP_TYPE_HYBRID); btMaps.setTag("Satellite"); } //-------------- Check if distance has changed ------------- int distanceData = mshPrefs.getInt("distanceData", Constants_API.initRange); int distanceDataOLD = mshPrefs.getInt("distanceDataOLD", Constants_API.initRange); //---------- Check if IssuesNo has changed --------- int IssuesNoAR = Integer.parseInt(mshPrefs.getString("IssuesNoAR", "40")); int IssuesNoAROLD = Integer.parseInt(mshPrefs.getString("IssuesNoAROLD", "40")); if (InternetConnCheck.getInstance(ctx).isOnline(ctx)) { if (distanceData != distanceDataOLD) { // ------- Broadcast Refresh through a handle Message msg = new Message(); msg.arg1 = 2; handlerBroadcastRefresh.sendMessage(msg); } else if (IssuesNoAR != IssuesNoAROLD) { // ------- Broadcast Refresh through a handle Message msg = new Message(); msg.arg1 = 3; handlerBroadcastRefresh.sendMessage(msg); } btRefresh.setVisibility(View.VISIBLE); } else { btRefresh.setVisibility(View.GONE); } //-------------- BT myIssues ------- btMyIss.bringToFront(); if (UserRealName.length() == 0) { btMyIss.setVisibility(View.GONE); } if (MyIssuesSW) btMyIss.setImageResource(R.drawable.ic_my_issues_gray); else btMyIss.setImageResource(R.drawable.ic_all_issues_gray); btMyIss.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Internal variables if (MyIssuesSW) MyIssuesSW = false; else MyIssuesSW = true; savePreferences("MyIssuesSW", MyIssuesSW, "boolean"); // Button appearance if (MyIssuesSW) btMyIss.setImageResource(R.drawable.my_issues_icon_gray32); else btMyIss.setImageResource(R.drawable.all_issues_icon_gray32); // now update the markers visible Message msg = new Message(); msg.arg1 = 2; handlerMarkersUPD.sendMessage(msg); } }); //-------- Init markers --------- Message msg = new Message(); msg.arg1 = 1; handlerMarkersUPD.sendMessage(msg); //----------- Flurry Analytics -------- if (mshPrefs.getBoolean("AnalyticsSW", true)) FlurryAgent.onStartSession(ctx, Constants_API.Flurry_Key); //----------------------------------- }
From source file:name.setup.dance.DanceStepApp.java
private void bindStepService() { Log.i(TAG, "[SERVICE] Bind"); bindService(new Intent(DanceStepApp.this, StepService.class), mConnection, Context.BIND_AUTO_CREATE + Context.BIND_DEBUG_UNBIND); }
From source file:com.appdevper.mediaplayer.activity.FullScreenPlayerActivity.java
@Override public void onStart() { super.onStart(); Intent intent = new Intent(this, MusicService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:cx.ring.client.HomeActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { Log.w(TAG, "onRequestPermissionsResult"); switch (requestCode) { case LocalService.PERMISSIONS_REQUEST: { if (grantResults.length == 0) { return; }//from w w w .j av a 2s .c o m for (int i = 0, n = permissions.length; i < n; i++) { switch (permissions[i]) { case Manifest.permission.RECORD_AUDIO: if (grantResults[i] != PackageManager.PERMISSION_GRANTED) { Log.e(TAG, "Missing required permission RECORD_AUDIO"); AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(R.string.start_error_title).setMessage(R.string.start_error_mic_required) .setIcon(R.drawable.ic_mic_black_48dp).setCancelable(false) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { finish(); } }); } builder.show(); return; } break; case Manifest.permission.READ_CONTACTS: SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPref.edit().putBoolean(SettingsFragment.KEY_PREF_CONTACTS, grantResults[i] == PackageManager.PERMISSION_GRANTED).apply(); break; } } if (!mBound) { Intent intent = new Intent(this, LocalService.class); startService(intent); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } break; } } }
From source file:ca.farrelltonsolar.classic.MonitorActivity.java
@Override public void onStart() { Log.d(getClass().getName(), String.format("onStart thread is %s", Thread.currentThread().getName())); super.onStart(); bindService(new Intent(this, ModbusService.class), modbusServiceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.abcvoipsip.ui.dialpad.DialerFragment.java
@Override public void onAttach(SupportActivity activity) { super.onAttach(activity); getActivity().bindService(new Intent(SipManager.INTENT_SIP_SERVICE), connection, Context.BIND_AUTO_CREATE); // timings.addSplit("Bind asked for two"); if (prefsWrapper == null) { prefsWrapper = new PreferencesWrapper(getActivity()); }/*from w ww.ja va 2s. c o m*/ if (dialFeedback == null) { dialFeedback = new DialingFeedback(getActivity(), false); } dialFeedback.resume(); }