Example usage for android.content Context BIND_AUTO_CREATE

List of usage examples for android.content Context BIND_AUTO_CREATE

Introduction

In this page you can find the example usage for android.content Context BIND_AUTO_CREATE.

Prototype

int BIND_AUTO_CREATE

To view the source code for android.content Context BIND_AUTO_CREATE.

Click Source Link

Document

Flag for #bindService : automatically create the service as long as the binding exists.

Usage

From source file:com.sharky.BillingService.java

private boolean bindToMarketBillingService() {
    try {// w  ww. ja  v  a  2  s  . c om
        boolean bindResult = bindService(new Intent(Consts.MARKET_BILLING_SERVICE_ACTION), this,
                Context.BIND_AUTO_CREATE);
        if (bindResult)
            return true;

    } catch (SecurityException e) {
    }
    return false;
}

From source file:com.example.android.leanback.MusicPlayerFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String json = inputStreamToString(getActivity().getResources().openRawResource(R.raw.media));
    MusicItem[] musicItems = new Gson().fromJson(json, MusicItem[].class);
    for (MusicItem i : musicItems) {
        mSongMetaDataList.add(i);/*from  ww  w .j  a v  a  2s .c om*/
    }
    Intent serviceIntent = new Intent(getActivity(), MediaSessionService.class);
    getActivity().bindService(serviceIntent, mPlaybackServiceConnection, Context.BIND_AUTO_CREATE);
}

From source file:com.yangtsaosoftware.pebblemessenger.services.PebbleCenter.java

@Override
public void onCreate() {
    super.onCreate();
    Handler pebbleCenterHandler = new PebbleCenterHandler();
    mPebbleCenterHandler = new Messenger(pebbleCenterHandler);
    Constants.log(TAG_NAME, "Create PebbleCenter Messenger.");
    loadPref();// ww w .j  a v  a  2s  . c o  m
    _contex = this;
    //   busyBegin=new Time();
    //        waitQueue=new ArrayDeque<PebbleMessage>();
    sendQueue = new ArrayDeque<PebbleDictionary>();
    bindService(new Intent(this, MessageProcessingService.class), connToMessageProcessing,
            Context.BIND_AUTO_CREATE);
    Thread prepareThread = new PrepareThread();
    prepareThread.start();
    Thread sendMsgThread = new SendMsgThread();
    sendMsgThread.start();
    isPebbleEnable = PebbleKit.isWatchConnected(_contex);
    PebbleKit.registerReceivedDataHandler(_contex, new PebbleKit.PebbleDataReceiver(Constants.PEBBLE_UUID) {
        @Override
        public void receiveData(Context context, int transactionId, PebbleDictionary data) {
            PebbleKit.sendAckToPebble(_contex, transactionId);
            //          appStatue++;
            Constants.log(TAG_NAME, "Received data form pebble");
            switch (data.getUnsignedIntegerAsLong(ID_COMMAND).intValue()) {
            case REQUEST_TRANSID_CALL_TABLE: {
                Constants.log(TAG_NAME, "Request call table.");
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_CALL_TABLE;
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
                break;
            case REQUEST_TRANSID_MESSAGE_TABLE: {
                Constants.log(TAG_NAME, "Request message table.");
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_MESSAGE_TABLE;
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
                break;
            case REQUEST_TRANSID_CALL: {
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_CALL;
                Bundle b = new Bundle();
                b.putString(MessageDbHandler.COL_CALL_ID, data.getString(ID_EXTRA_DATA));
                Constants.log(TAG_NAME, "Request call id:" + data.getString(ID_EXTRA_DATA));

                msg.setData(b);
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }

            }
                break;
            case REQUEST_TRANSID_MESSAGE:
                clean_SendQue();
                Message msg = Message.obtain();
                msg.what = MessageProcessingService.MSG_GET_MESSAGE;
                Bundle b = new Bundle();
                b.putString(MessageDbHandler.COL_MESSAGE_ID, data.getString(ID_EXTRA_DATA));
                Constants.log(TAG_NAME, "Request message id:" + data.getString(ID_EXTRA_DATA));

                msg.setData(b);
                try {
                    rMessageProcessingHandler.send(msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
                break;
            case REQUEST_TRANSID_PICKUP_PHONE:
                TelephonyManager telMag = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                Constants.log("Receivephone", "Receive phone:" + data.getString(ID_EXTRA_DATA2));
                if (telMag.getCallState() == TelephonyManager.CALL_STATE_RINGING) {
                    switch (data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).intValue()) {
                    case REQUEST_EXTRA_SPEAKER_ON:
                        answerCall(true);
                        break;
                    case REQUEST_EXTRA_SPEAKER_OFF:
                        answerCall(false);
                        break;
                    }
                } else {
                    switch (data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).intValue()) {
                    case REQUEST_EXTRA_SPEAKER_ON:
                        dialNumber(data.getString(ID_EXTRA_DATA2), true);
                        break;
                    case REQUEST_EXTRA_SPEAKER_OFF:
                        dialNumber(data.getString(ID_EXTRA_DATA2), false);
                        break;
                    }

                }
                //                pebbleBusy = false;
                break;
            case REQUEST_TRANSID_HANGOFF_PHONE:
                endCall();
                //                pebbleBusy=false;

                break;
            case REQUEST_TRANSID_HANGOFF_SMS1:
                Constants.log(TAG_NAME, "Request hangoff and send sms1");

                endCall();
                doSendSMSTo(data.getString(ID_EXTRA_DATA), sms1);
                //               pebbleBusy=false;

                break;
            case REQUEST_TRANSID_HANGOFF_SMS2:
                Constants.log(TAG_NAME, "Request hangoff and send sms2");

                endCall();
                doSendSMSTo(data.getString(ID_EXTRA_DATA), sms2);
                //              pebbleBusy=false;

                break;
            case REQUEST_TRANSID_CLOSE_APP:
                Constants.log(TAG_NAME, "Request close app command.");
                sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
                //               need_delay=true;

                break;
            case REQUEST_TRANSID_NEXTPAGE:
                Constants.log(TAG_NAME, "Request send next page.");

                sendMsgThreadHandler.sendEmptyMessage(SEND_NEXT_PAGE);
                break;
            case REQUEST_TRANSID_READ_NOTIFY: {
                Constants.log(TAG_NAME, "Request  read msg");
                Message read_msg = Message.obtain();
                read_msg.what = MessageProcessingService.MSG_READ;
                Bundle bd = new Bundle();
                bd.putString(MessageDbHandler.COL_MESSAGE_ID,
                        data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).toString());
                read_msg.setData(bd);
                try {
                    rMessageProcessingHandler.send(read_msg);
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
                break;
            case REQUEST_TRANSID_IM_FREE:
                Constants.log(TAG_NAME, "Request pebble app is free to receive data.");

                //               need_delay = data.getUnsignedInteger(ID_EXTRA_DATA).intValue() == REQUEST_EXTRA_DELAY_ON ;
                //               clean_SendQue();
                break;
            case REQUEST_TRANSID_VERSION: {
                send_test_get_return = true;
                String result = data.getString(ID_EXTRA_DATA);
                Constants.log("PmpVersion", result);
                StringTokenizer tokens = new StringTokenizer(result, ".");

                Intent inner_intent = new Intent(SetupFragment.class.getName());
                inner_intent.putExtra(Constants.BROADCAST_VERSION,
                        new byte[] { Byte.parseByte(tokens.nextToken()), Byte.parseByte(tokens.nextToken()),
                                Byte.parseByte(tokens.nextToken()) });
                LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent);
                sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
                break;
            }
            }
        }
    });

    PebbleKit.registerReceivedAckHandler(_contex, new PebbleKit.PebbleAckReceiver(Constants.PEBBLE_UUID) {
        @Override
        public void receiveAck(Context context, int transactionId) {
            Constants.log(TAG_NAME, "Get a receiveAck:" + String.valueOf(transactionId));
            switch (transactionId) {
            case TRANS_ID_COMMON:
                Constants.log(TAG_NAME, "Send continue...");
                //                  pebbleBusy=true;
                sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE);
                break;
            case TRANS_ID_END:
                send_full_page = true;
                break;
            case TRANS_ID_EMPTY:
                //                 pebbleBusy=true;
                sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE);
                break;
            case TRANS_ID_TEST: {
                break;
            }
            }
        }
    });

    PebbleKit.registerReceivedNackHandler(_contex, new PebbleKit.PebbleNackReceiver(Constants.PEBBLE_UUID) {
        @Override
        public void receiveNack(Context context, int transactionId) {
            Constants.log(TAG_NAME, "Get a receivedNack:" + String.valueOf(transactionId));
            if (PebbleKit.isWatchConnected(_contex)) {
                switch (transactionId) {
                case TRANS_ID_COMMON:
                    sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE);
                    break;
                case TRANS_ID_END:
                    send_full_page = true;
                    break;
                case TRANS_ID_EMPTY:
                    //                   appStatue=0;
                    sendMsgThreadHandler.sendEmptyMessage(SEND_OPEN_APP);
                    break;
                case TRANS_ID_TEST: {
                    Intent inner_intent = new Intent(SetupFragment.class.getName());
                    inner_intent.putExtra(Constants.BROADCAST_VERSION, new byte[] { 0, 0, 0 });
                    LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent);
                }
                }
            } else {
                sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
            }

        }
    });

    PebbleKit.registerPebbleConnectedReceiver(_contex, new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            isPebbleEnable = true;
        }
    });

    PebbleKit.registerPebbleDisconnectedReceiver(_contex, new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            isPebbleEnable = false;
            sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP);
        }
    });

    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:
                loadPref();
                break;
            case Constants.BROADCAST_CALL_IDLE:
                if (callEnable) {
                    sendMsgThreadHandler.sendEmptyMessage(SEND_CALL_END);
                }
                break;
            case Constants.BROADCAST_CALL_HOOK:
                if (callEnable) {
                    sendMsgThreadHandler.sendEmptyMessage(SEND_CALL_HOOK);
                }
                break;
            case Constants.BROADCAST_PEBBLE_TEST:
                if (isPebbleEnable) {
                    prepareThreadHandler.sendEmptyMessage(PREPARE_TEST);
                }
                break;
            }
        }
    };
    IntentFilter intentFilter = new IntentFilter(PebbleCenter.class.getName());
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(br, intentFilter);
}

From source file:com.singularityeye.eyetrack.MapsActivity.java

/**
 * The activity is visible and interacts with the service.
 * Bind to local service. Automatically create the service as long as the binding exists.
 *///from w  w  w . j  a  va 2  s .com
// in cache, visible;
@Override
protected void onStart() {
    Log.d("ONSTART", "ON_START !"); // debug
    // bind to local service; it calls onServiceConnected on the ServiceConnection,
    // to deliver the IBinder that the client can use to communicate with the service;
    // note: multiple clients can connect to service at once,
    // however the system use the same IBinder (which first client binds) to
    // any additional clients that bind without calling onBind() again
    // FLAG note: automatically create the service as long as the binding exists
    bindService(new Intent(this, BoundService.class), connection, Context.BIND_AUTO_CREATE); // start sending soap requests
    super.onStart();
}

From source file:com.cdvdev.subscriptiondemo.helpers.IabHelper.java

/**
 * Setup in-app billing//from w  w  w  .j ava2  s  . c om
 */
public void startSetup(final OnIabSetupFinishListener finishListener) {
    logDebug("Starting in-app billing setup.");
    checkNotDisposed();
    // If already set up, can't do it again.
    if (mSetupDone)
        throw new IllegalStateException("IAB helper is already set up.");

    // Binding to IInAppBillingService
    mServiceConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            if (mDisposed)
                return;
            logDebug("Billing service connected.");
            mIInAppBillingService = IInAppBillingService.Stub.asInterface(service);
            String packageName = mContext.getPackageName();

            try {
                logDebug("Checking for in-app billing 3 support.");
                //check for in-app billing v3 support
                int response = mIInAppBillingService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP);
                if (response != BILLING_RESPONSE_RESULT_OK) {
                    if (finishListener != null) {
                        finishListener.onIabSetupFinished(
                                new IabResult(response, "Error checking for billing v3 support."));
                    }

                    // if in-app purchases aren't supported, neither are subscriptions
                    mSubscriptionsSupported = false;
                    mSubscriptionUpdateSupported = false;
                    return;
                } else {
                    logDebug("In-app billing version 3 supported for " + packageName);
                }

                // Check for v5 subscriptions support. This is needed for
                // getBuyIntentToReplaceSku which allows for subscription update
                response = mIInAppBillingService.isBillingSupported(5, packageName, ITEM_TYPE_SUBS);
                if (response == BILLING_RESPONSE_RESULT_OK) {
                    logDebug("Subscription re-signup AVAILABLE.");
                    mSubscriptionUpdateSupported = true;
                } else {
                    logDebug("Subscription re-signup not available.");
                    mSubscriptionUpdateSupported = false;
                }

                if (mSubscriptionUpdateSupported) {
                    mSubscriptionsSupported = true;
                } else {
                    // check for v3 subscriptions support
                    response = mIInAppBillingService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS);
                    if (response == BILLING_RESPONSE_RESULT_OK) {
                        logDebug("Subscriptions AVAILABLE.");
                        mSubscriptionsSupported = true;
                    } else {
                        logDebug("Subscriptions NOT AVAILABLE. Response: " + response);
                        mSubscriptionsSupported = false;
                        mSubscriptionUpdateSupported = false;
                    }
                }

                mSetupDone = true;

            } catch (RemoteException e) {
                if (finishListener != null) {
                    finishListener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION,
                            "RemoteException while setting up in-app billing."));
                }
                e.printStackTrace();
                return;
            }

            if (finishListener != null) {
                finishListener
                        .onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful."));
            }
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            logDebug("Billing service disconnected.");
            mIInAppBillingService = null;
        }
    };

    //create service
    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {
        mContext.bindService(serviceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
    } else {
        // no service available to handle that Intent
        if (finishListener != null) {
            finishListener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
                    "Billing service unavailable on device."));
        }
    }

}

From source file:com.example.administrator.myapplication2._3_HB._3_MainActivity.java

/**
 * Start service if it's not running// w ww .j a  va  2 s  .  co m
 */
private void doStartService() {
    Log.d(TAG, "# Activity - doStartService()");
    startService(new Intent(this, BTCTemplateService.class));
    bindService(new Intent(this, BTCTemplateService.class), mServiceConn, Context.BIND_AUTO_CREATE);
}

From source file:com.voiceblue.phone.ui.SipHome.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //prefWrapper = new PreferencesWrapper(this);
    prefProviderWrapper = new PreferencesProviderWrapper(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.sip_home);//from  w  w  w  .  jav a 2 s  .c o m
    final ActionBar ab = getSupportActionBar();
    ab.setDisplayShowHomeEnabled(false);
    ab.setDisplayShowTitleEnabled(false);
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // showAbTitle = Compatibility.hasPermanentMenuKey

    Tab dialerTab = ab.newTab().setContentDescription(R.string.dial_tab_name_text)
            .setIcon(R.drawable.ic_ab_dialer_holo_dark);
    Tab callLogTab = ab.newTab().setContentDescription(R.string.calllog_tab_name_text)
            .setIcon(R.drawable.ic_ab_history_holo_dark);
    /*Tab favoritesTab = null;
    if(CustomDistribution.supportFavorites()) {
    favoritesTab = ab.newTab()
            .setContentDescription(R.string.favorites_tab_name_text)
            .setIcon(R.drawable.ic_ab_favourites_holo_dark);
    }
    */
    Tab messagingTab = null;

    /*if (CustomDistribution.supportMessaging()) {
    messagingTab = ab.newTab()
            .setContentDescription(R.string.messages_tab_name_text)
            .setIcon(R.drawable.ic_ab_text_holo_dark);
    }*/

    Tab voiceBlueWebTab = ab.newTab().setIcon(R.drawable.ic_action_web_site);
    Tab customerInfoTab = ab.newTab().setIcon(R.drawable.ic_action_user);

    /*warningTab = ab.newTab().setIcon(android.R.drawable.ic_dialog_alert);
    warningTabfadeAnim = ObjectAnimator.ofInt(warningTab.getIcon(), "alpha", 255, 100);
    warningTabfadeAnim.setDuration(1500);
    warningTabfadeAnim.setRepeatCount(ValueAnimator.INFINITE);
    warningTabfadeAnim.setRepeatMode(ValueAnimator.REVERSE);
    */
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, getSupportActionBar(), mViewPager);
    mTabsAdapter.addTab(dialerTab, DialerFragment.class, TAB_ID_DIALER);
    mTabsAdapter.addTab(callLogTab, CallLogListFragment.class, TAB_ID_CALL_LOG);

    /*if(favoritesTab != null) {
              mTabsAdapter.addTab(favoritesTab, FavListFragment.class, TAB_ID_FAVORITES);
    }
            
    if (messagingTab != null) {
    mTabsAdapter.addTab(messagingTab, ConversationsListFragment.class, TAB_ID_MESSAGES);
    }
    */

    mTabsAdapter.addTab(voiceBlueWebTab, VoiceBlueWebFragment.class, TAB_ID_VBWEB);
    mTabsAdapter.addTab(customerInfoTab, VoiceBlueCustomerInfoFragment.class, TAB_ID_CUSTOMER_INFO);

    hasTriedOnceActivateAcc = false;

    if (!prefProviderWrapper.getPreferenceBooleanValue(SipConfigManager.PREVENT_SCREEN_ROTATION)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    selectTabWithAction(getIntent());
    Log.setLogLevel(prefProviderWrapper.getLogLevel());

    if (!OTAConfig.checkPlayServices(this)) {
        Log.e(THIS_FILE, "Google Play Services not available");
        finish();
        return;
    }

    /*
     * Register this App to be able to receive Over-The-Air configuration
     * parameters
     */
    OTAConfig.registerApp(this);

    bindService(new Intent(this, SipService.class), mConnection, Context.BIND_AUTO_CREATE);
    /*
    // Async check
    asyncSanityChecker = new Thread() {
    public void run() {
        asyncSanityCheck();
    };
    };
    asyncSanityChecker.start();
    */
}

From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreate() start");
    // Log.d(TAG,"called first");

    super.onCreate(savedInstanceState); // this calls onAccountChanged()
                                        // when ownCloud Account is valid
                                        // requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    if (AccountUtils.getCurrentOwnCloudAccount(getBaseContext()) != null) {
        Intent intent = new Intent(this, InitialPageActivity.class);
        startActivity(intent);/*from  ww w  .j a va2s  .  c  o m*/
    }
    mHandler = new Handler();

    // / bindings to transference services
    mUploadConnection = new ListServiceConnection();
    mDownloadConnection = new ListServiceConnection();
    bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE);
    bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE);
    shareNotifier = new NotificationCompat.Builder(this).setContentTitle("File Shared")
            .setSmallIcon(R.drawable.icon);

    Button shareButton = (Button) findViewById(R.id.shareItem);
    Intent fileShareIntent = new Intent(this, FileDisplayActivity.class);
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, fileShareIntent, 0);
    shareNotifier.setContentIntent(pIntent);
    shareNotifier.setAutoCancel(true);
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    dataSource = new DbFriends(this);
    // ContentResolver.setIsSyncable(getAccount(),
    // AccountAuthenticator.AUTHORITY, 1);
    // ContentResolver.setSyncAutomatically(getAccount(),
    // AccountAuthenticator.AUTHORITY,true);
    // broadcast receiver that is called by the service which downloads the
    // files to the phone
    instantdownloadreceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String message = intent.getStringExtra("message");
            instantDownloadFile();
            // make the http request and update the ui to include the sharer
            // information

            // unregisterReceiver(instantdownloadreceiver);
        }
    };

    // PIN CODE request ; best location is to decide, let's try this first
    if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN)
            && savedInstanceState == null) {
        requestPinCode();
    }

    // / file observer
    Intent observer_intent = new Intent(this, FileObserverService.class);
    observer_intent.putExtra(FileObserverService.KEY_FILE_CMD, FileObserverService.CMD_INIT_OBSERVED_LIST);
    startService(observer_intent);

    // / Load of saved instance state
    if (savedInstanceState != null) {
        mWaitingToPreview = (OCFile) savedInstanceState
                .getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW);

    } else {
        mWaitingToPreview = null;
    }

    // / USER INTERFACE

    // Inflate and set the layout view
    setContentView(R.layout.files);
    mDualPane = getResources().getBoolean(R.bool.large_land_layout);
    mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
    mRightFragmentContainer = findViewById(R.id.right_fragment_container);
    if (savedInstanceState == null) {
        createMinFragments();
    }

    // Action bar setup
    mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
    getSupportActionBar().setHomeButtonEnabled(true); // mandatory since
                                                      // Android ICS,
                                                      // according to the
                                                      // official
                                                      // documentation
    setSupportProgressBarIndeterminateVisibility(false); // always AFTER
                                                         // setContentView(...)
                                                         // ; to work around
                                                         // bug in its
                                                         // implementation

    Log_OC.d(TAG, "onCreate() end");
}

From source file:com.filepager.afilechooser.FileChooserActivity.java

@Override
protected void onStart() {
    super.onStart();
    Intent intent = new Intent(this, MasterService.class);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

}

From source file:src.com.nustats.pacelogger.RecordingActivity.java

void cancelRecording() {
    Intent rService = new Intent(this, RecordingService.class);
    ServiceConnection sc = new ServiceConnection() {
        public void onServiceDisconnected(ComponentName name) {
        }/*from  w  w  w  .  j a v  a 2  s  .c  o  m*/

        public void onServiceConnected(ComponentName name, IBinder service) {
            IRecordService rs = (IRecordService) service;
            rs.cancelRecording();
            unbindService(this);
        }
    };
    // This should block until the onServiceConnected (above) completes.
    bindService(rService, sc, Context.BIND_AUTO_CREATE);
}