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.SecUpwN.AIMSICD.activities.MapViewerOsmDroid.java
/** * Called when the activity is first created. *///from ww w . ja v a2 s . co m @Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "Starting MapViewer"); super.onCreate(savedInstanceState); mContext = this; setContentView(R.layout.map); setUpMapIfNeeded(); mDbHelper = new AIMSICDDbAdapter(mContext); // Bind to LocalService Intent intent = new Intent(mContext, AimsicdService.class); mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); }
From source file:com.csipsimple.ui.messages.MessageFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); getActivity().bindService(new Intent(getActivity(), SipService.class), connection, Context.BIND_AUTO_CREATE); }
From source file:com.shinymetal.gradereport.AbstractActivity.java
public void doBindService() { Intent intent = null;/* w ww .jav a 2 s . c o m*/ intent = new Intent(this, DiaryUpdateService.class); // Create a new Messenger for the communication back // From the Service to the Activity Messenger messenger = new Messenger(mHandler); intent.putExtra("MESSENGER", messenger); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:fr.mixit.android.ui.GenericMixItActivity.java
protected void doBindService() { if (DEBUG_MODE) { Log.d(TAG, "doBindService()"); }/*w w w . j av a 2s.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. bindService(new Intent(this, MixItService.class), mConnection, Context.BIND_AUTO_CREATE); mIsBound = true; }
From source file:org.peercast.core.PeerCastServiceController.java
/** * /*from ww w . j a v a 2 s .co m*/ * context.bindService??? * @return */ public boolean bindService() { if (!isInstalled()) { Log.e(TAG, "PeerCast not installed."); return false; } context.bindService(new Intent(context, AndroidUpnpServiceImpl.class), pmServiceConnection, Context.BIND_AUTO_CREATE); Intent intent = new Intent(CLASS_NAME_PEERCAST_SERVICE); return context.bindService(intent, serviceConn, Context.BIND_AUTO_CREATE); }
From source file:com.eurecalab.eureca.fragments.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_settings, container, false); reverseColor = (SwitchCompat) rootView.findViewById(R.id.reverseColor); apply = (Button) rootView.findViewById(R.id.apply); colorSpinner = (Spinner) rootView.findViewById(R.id.colorSpinner); signOutButton = (Button) rootView.findViewById(R.id.sign_out_button); loggedUser = (TextView) rootView.findViewById(R.id.logged_user); appLicense = (TextView) rootView.findViewById(R.id.app_license); upgrade = (Button) rootView.findViewById(R.id.upgrade); expiresIn = (TextView) rootView.findViewById(R.id.expires_in); parent = getActivity();//ww w.jav a2s . c o m gs = (GlobalState) parent.getApplication(); user = gs.getAuthenticatedUser(); loggedUser.setText(user.getDisplayName()); GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail().build(); mGoogleApiClient = new GoogleApiClient.Builder(parent) .enableAutoManage(parent, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build(); signOutButton.setOnClickListener(this); upgrade.setOnClickListener(this); updateUI(); TypedArray colorArray = getResources().obtainTypedArray(R.array.theme_colors); int[] colors = new int[colorArray.length()]; int defaultColor = ContextCompat.getColor(getActivity(), R.color.color_primary_red); for (int i = 0; i < colors.length; i++) { colors[i] = colorArray.getColor(i, defaultColor); } colorArray.recycle(); colorSpinnerAdapter = new ColorSpinnerAdapter(getActivity(), colors); colorSpinner.setAdapter(colorSpinnerAdapter); apply.setOnClickListener(this); sharedPreferences = getActivity().getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE); int color = sharedPreferences.getInt(getString(R.string.saved_color), R.color.color_primary_red); boolean reverse = sharedPreferences.getBoolean(getString(R.string.saved_reverse), false); int position = -1; for (int i = 0; i < colors.length; i++) { if (colors[i] == color) { position = i; break; } } colorSpinner.setSelection(position); reverseColor.setChecked(reverse); ServiceConnection mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { mService = IInAppBillingService.Stub.asInterface(service); } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); getActivity().bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); return rootView; }
From source file:com.ty.highway.highwaysystem.ui.activity.basic.BaseActivity.java
public void updateVersion() { if (CommonUtils.isNetworkConnected(mContext)) { showSpotsDialog("...", false); HashMap<String, String> map = new HashMap<String, String>(); HashMap<String, String> mapName = new HashMap<String, String>(); HashMap<String, String> mapType = new HashMap<String, String>(); map.put("key", Constants.KEY); mapName.put("methodName", Constants.METHOD_LOADAPPVERSION); mapType.put("urlType", Constants.SERVICEURL_TYPE_BASEINFO); BaseNetAsyncTask asyncTask = new BaseNetAsyncTask(new NetResquestListener() { @Override/*from w ww .ja v a 2 s.co m*/ public void onSuccess(String response) { if (response != null) { if (response.contains("\"r\":\"ok")) { AppVersionResultBean bean = new Gson().fromJson(response, AppVersionResultBean.class); AppVersionResultBean.AppVersionBean info = bean.getS(); int versionCode = Integer.parseInt(info.getAppVersion()); if (versionCode > CommonUtils.getVersionCode(mContext)) { mApkUrl = info.getAppPath(); AlertDialog.Builder build = new AlertDialog.Builder(mContext); build.setTitle("?").setMessage("???") .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent it = new Intent(mContext, AppDownloadService.class); bindService(it, mDownloadConn, Context.BIND_AUTO_CREATE); } }).setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); } else { if (isSettingUpdate) { isSettingUpdate = false; ToastUtils.show(mContext, "?"); } } } else { } hideSpotsDialog(); } } @Override public void onError(String errormsg) { hideSpotsDialog(); } }, mContext); asyncTask.execute(map, mapName, mapType); } else { SnackbarUtils.show(mContext, ""); } }
From source file:com.secupwn.aimsicd.ui.fragments.MapFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); log.info("Starting MapViewer"); setUpMapIfNeeded();/*from w w w.j a v a 2 s .co m*/ mDbHelper = new RealmHelper(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.yangtsaosoftware.pebblemessenger.activities.ToolsFragment.java
@Override public void onResume() { super.onResume(); _context.bindService(new Intent(getActivity(), MessageProcessingService.class), connToMessageProcess, Context.BIND_AUTO_CREATE); }