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.netcompss.ffmpeg4android_client.BaseWizard.java
protected void bindService() { Log.d(Prefs.TAG, " bindService() called"); if (conn == null) { conn = new RemoteServiceConnection(); ///Intent i = new Intent(); Intent i = new Intent("com.netcompss.ffmpeg4android.FFMpegRemoteServiceBridge"); if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) { i.setPackage("com.netcompss.ffmpeg4android"); }//from w w w.ja va 2s. c o m bindService(i, conn, Context.BIND_AUTO_CREATE); Log.d(Prefs.TAG, "Client bindService()"); } else { Log.d(Prefs.TAG, " Client Cannot bind - service already bound"); //Toast.makeText(this, "Client Cannot bind - service already bound", Toast.LENGTH_SHORT).show(); } }
From source file:fr.s13d.photobackup.preferences.PBPreferenceFragment.java
public void onTestSuccess() { final Intent serviceIntent = new Intent(getActivity(), PBService.class); getActivity().startService(serviceIntent); getActivity().bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); isBoundToService = true;/*from www. j a v a 2 s . com*/ getActivity().invalidateOptionsMenu(); }
From source file:com.teeptrak.controller.MainActivity.java
private void initUartService() { Intent bindIntent = new Intent(this, UartService.class); bindService(bindIntent, mUartServiceConnection, Context.BIND_AUTO_CREATE); LocalBroadcastManager.getInstance(this).registerReceiver(UARTStatusChangeReceiver, makeGattUpdateIntentFilter()); }
From source file:com.github.mjdev.libaums.usbfileman.MainActivity.java
@Override protected void onStart() { super.onStart(); startService(serviceIntent); bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); ActionBar actionbar = getSupportActionBar(); if (actionbar != null) { actionbar.show();//from ww w . j av a 2 s. c o m } // ????APK???????BG???onCreate??Activity?? // Intent?????????????? if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { finish(); return; } if (!isRunningJunit) { setContentView(R.layout.activity_main); FirebaseRemoteConfigUtil.initialize(); LikeView likeView = (LikeView) findViewById(R.id.like_view); likeView.setObjectIdAndType(String.format(getString(R.string.app_googlePlay_url), getPackageName()), LikeView.ObjectType.PAGE); // Create the interstitial. mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId(getString(R.string.ad_mob_id)); // Create ad request. final AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators .addTestDevice("1BEC3806A9717F2A87F4D1FC2039D5F2") // An device ID ASUS .addTestDevice("64D37FCE47B679A7F4639D180EC4C547").build(); // Begin loading your interstitial. mInterstitialAd.loadAd(adRequest); mInterstitialAd.setAdListener(new AdListener() { @Override public void onAdLeftApplication() { super.onAdLeftApplication(); enableNewFunction = true; supportInvalidateOptionsMenu(); } @Override public void onAdClosed() { super.onAdClosed(); // ????????????? if (!enableNewFunction) { // Begin loading your interstitial. mInterstitialAd.loadAd(adRequest); } else { LayoutInflater inflater = LayoutInflater.from(MainActivity.this); final View layout = inflater.inflate(R.layout.new_function_dialog, (ViewGroup) findViewById(R.id.layout_root_new)); new MaterialStyledDialog(MainActivity.this).setTitle("?").setDescription( "????????\n???????????") .setCustomView(layout).setIcon(R.drawable.ic_fiber_new_white_48dp) .setHeaderDrawable(R.drawable.pattern_bg_blue) .setPositive(getString(R.string.ok), null).show(); RealmUtil.insertHistoryItemAsync(realm, createHistoryItemData(), new RealmUtil.realmTransactionCallbackListener() { @Override public void OnSuccess() { } @Override public void OnError() { } }); } } }); // FIXME : ?????? AdView mAdView = (AdView) findViewById(R.id.adView); // mAdView.loadAd(adRequest); DefaultLayoutPromptView promptView = (DefaultLayoutPromptView) findViewById(R.id.prompt_view); final BasePromptViewConfig basePromptViewConfig = new BasePromptViewConfig.Builder() .setUserOpinionQuestionTitle(getString(R.string.prompt_title)) .setUserOpinionQuestionPositiveButtonLabel(getString(R.string.prompt_btn_yes)) .setUserOpinionQuestionNegativeButtonLabel(getString(R.string.prompt_btn_no)) .setPositiveFeedbackQuestionTitle(getString(R.string.prompt_title_feedback)) .setPositiveFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure)) .setPositiveFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow)) .setCriticalFeedbackQuestionTitle(getString(R.string.prompt_title_feedback_2)) .setCriticalFeedbackQuestionNegativeButtonLabel(getString(R.string.prompt_btn_notnow)) .setCriticalFeedbackQuestionPositiveButtonLabel(getString(R.string.prompt_btn_sure)) .setThanksTitle(getString(R.string.prompt_thanks)).build(); promptView.applyBaseConfig(basePromptViewConfig); Amplify.getSharedInstance().promptIfReady(promptView); mAnimationBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); int buttonColor = ContextCompat.getColor(this, R.color.colorPrimary); int buttonPressedColor = ContextCompat.getColor(this, R.color.colorPrimaryDark); mbtnStart = (ActionButton) findViewById(R.id.fabStart); mbtnStart.setButtonColor(buttonColor); mbtnStart.setButtonColorPressed(buttonPressedColor); // ? new MaterialIntroView.Builder(this).enableDotAnimation(false).enableIcon(true) .setFocusGravity(FocusGravity.CENTER).setFocusType(Focus.MINIMUM).setDelayMillis(500) .enableFadeAnimation(true).performClick(true).setInfoText(getString(R.string.intro_description)) .setTarget(mbtnStart).setUsageId(TUTORIAL_ID) //THIS SHOULD BE UNIQUE ID .dismissOnTouch(true).show(); mbtnStart.setOnClickListener(this); Intent mAlertServiceIntent = new Intent(MainActivity.this, AlertService.class); // ?????????????(???????) // ???????? if (!Utility.isTabletNotPhone(this)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } mTwitter = TwitterUtility.getTwitterInstance(this); mCallbackURL = getString(R.string.twitter_callback_url); mPlusOneButton = (PlusOneButton) findViewById(R.id.plus_one_button); // Refresh the state of the +1 button each time the activity receives focus. mPlusOneButton.initialize( String.format(getString(R.string.app_googlePlay_url_plusOne), getPackageName()), PLUS_ONE_REQUEST_CODE); RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.rtlMain); relativeLayout.setOnClickListener(this); findViewById(R.id.llStepCount).setVisibility(mShouldShowPedometer ? View.VISIBLE : View.INVISIBLE); // // Service?????Activity?Destroy????Activity?????? // // UI?Service????????Service??????????Bind???????? // // Application???? // if (((AlertApplication) getApplication()).IsRunningService()) { // btnIsStarted = false; // setStartButtonFunction(findViewById(R.id.fabStart)); // } // // startService(mAlertServiceIntent); bindService(mAlertServiceIntent, mConnection, Context.BIND_AUTO_CREATE); } mIsToastOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "message", true); mIsVibrationOn = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "vibrate", true); mToastPosition = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "toastPosition", Gravity.CENTER); mAlertStartAngle = SharedPreferencesUtil.getInt(this, SETTING_SHAREDPREF_NAME, "progress", ALERT_ANGLE_INITIAL_VALUE) + ALERT_ANGLE_INITIAL_OFFSET; mShouldShowPedometer = SharedPreferencesUtil.getBoolean(this, SETTING_SHAREDPREF_NAME, "pedometer", true); // ?????(update??) or ??? enableNewFunction = RealmUtil.hasHistoryItem(realm) || SharedPreferencesUtil.getBoolean(this, AD_STATUS_SHAREDPREF_NAME, "AD_STATUS_SHAREDPREF_NAME", false); }
From source file:com.scooter1556.sms.android.activity.MainActivity.java
@Override protected void onStart() { super.onStart(); if (audioPlayerIntent == null) { audioPlayerIntent = new Intent(this, AudioPlayerService.class); bindService(audioPlayerIntent, audioPlayerConnection, Context.BIND_AUTO_CREATE); startService(audioPlayerIntent); }/*w w w .j a v a2s . c o m*/ }
From source file:com.kasungunathilaka.sarigama.ui.HomeActivity.java
@Override protected void onStart() { super.onStart(); Intent intent = new Intent(this, PlayerService.class); LocalBroadcastManager.getInstance(HomeActivity.this).registerReceiver((broadcastReceiver), new IntentFilter(ON_PLAY)); LocalBroadcastManager.getInstance(HomeActivity.this).registerReceiver((broadcastReceiver), new IntentFilter(ON_PAUSE)); LocalBroadcastManager.getInstance(HomeActivity.this).registerReceiver((broadcastReceiver), new IntentFilter(ON_PREPARED)); LocalBroadcastManager.getInstance(HomeActivity.this).registerReceiver((broadcastReceiver), new IntentFilter(ON_COMPLETED)); LocalBroadcastManager.getInstance(HomeActivity.this).registerReceiver((broadcastReceiver), new IntentFilter(ON_PREPARING)); LocalBroadcastManager.getInstance(HomeActivity.this).registerReceiver((broadcastReceiver), new IntentFilter(ON_PLAYER_ENTER)); LocalBroadcastManager.getInstance(HomeActivity.this).registerReceiver((broadcastReceiver), new IntentFilter(ON_PLAYER_EXIT)); bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.binomed.showtime.android.screen.movie.CineShowTimeMovieFragment.java
public void bindService() { interaction.getMainContext().bindService( new Intent(interaction.getMainContext(), CineShowTimeMovieService.class), mConnection, Context.BIND_AUTO_CREATE); }
From source file:com.zion.htf.ui.fragment.ArtistSoundcloudFragment.java
/** * Requests the activity to bind to the service, to allow easier communication with the service. * @param activity the current fragment's activity, acting as a proxy to the service *///from w w w . j a v a 2 s . co m private void requestServiceBond(Activity activity) { ArtistSoundcloudFragment.MediaPlayerServiceProxy serviceProxy = (ArtistSoundcloudFragment.MediaPlayerServiceProxy) activity; ((AbstractServiceProxyActivity) activity).registerObserver(this); activity.bindService(new Intent(activity, MediaPlayerService.class), serviceProxy.getServiceConnection(), Context.BIND_AUTO_CREATE); }
From source file:com.android.deskclock.alarms.AlarmActivity.java
/** * Bind AlarmService if not yet bound./*from w ww .j a v a 2 s . c o m*/ */ private void bindAlarmService() { if (!mServiceBound) { final Intent intent = new Intent(this, AlarmService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); mServiceBound = true; } }