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:Main.java

private static void bindToService(Intent intent, Context context, ServiceConnection callback) {
    Context realActivity = context.getApplicationContext();
    if (realActivity == null) {
        realActivity = context;/*  w  ww .j  a  va  2  s .co  m*/
    }
    ContextWrapper cw = new ContextWrapper(realActivity);
    cw.startService(intent);
    cw.bindService(intent, callback, Context.BIND_AUTO_CREATE);
}

From source file:ServiceConsumerActivity.java

void bind() {
    Intent intent = new Intent();
    intent.setClassName("com.allyourcode.p03_03_13", "com.allyourcode.p03_03_13.MyWeatherService");
    isBound = bindService(intent, connection, Context.BIND_AUTO_CREATE);
}

From source file:com.inovex.zabbixmobile.activities.fragments.BaseServiceConnectedFragment.java

@Override
public void onStart() {
    super.onStart();
    Log.d(TAG, "onStart");
    // we need to do this after the view was created!!
    Intent intent = new Intent(getActivity(), ZabbixDataService.class);
    getActivity().getApplicationContext().bindService(intent, this, Context.BIND_AUTO_CREATE);
}

From source file:com.commonsware.android.weather.WeatherFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRetainInstance(true);/* w  ww .j  a  v a 2s . c  o m*/

    getActivity().getApplicationContext().bindService(new Intent(getActivity(), WeatherService.class), this,
            Context.BIND_AUTO_CREATE);

    mgr = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    mgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3600000, 1000, this);
}

From source file:de.schildbach.wallet.data.BlockchainStateLiveData.java

@Override
protected void onActive() {
    broadcastManager.registerReceiver(receiver, new IntentFilter(BlockchainService.ACTION_BLOCKCHAIN_STATE));
    application.bindService(new Intent(application, BlockchainService.class), this, Context.BIND_AUTO_CREATE);
}

From source file:angeloid.dreamnarae.TTS_Biling.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.biling);//from w  w w.jav  a2  s .c  o  m
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(TTS_Biling.this);
    Biling_Friends();
    int temp_isPro = sharedPrefs.getInt("License", 0);
    if (temp_isPro == TRUE)
        isPro = true;
    Intent intent = getIntent();
    String Type = intent.getStringExtra("Type");
    if (Type.equals("Narae")) {
        sku = "dntts_narae";
        Biling_Narae();
    } else if (Type.equals("Friends")) {
        sku = "dntts_friends";
        Biling_Friends();
    }
    bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn,
            Context.BIND_AUTO_CREATE);
}

From source file:eu.andlabs.studiolounge.gcp.GCPService.java

public static Lounge bind(Context ctx) {
    Log.d("GCP-Service", "binding GCP Service");
    String name = LoginManager.getInstance(ctx).getUserId().getPlayername();
    Lounge lounge = new Lounge(ctx);
    Intent intent = new Intent(ctx, GCPService.class);
    intent.putExtra("packageName", ctx.getPackageName());
    intent.putExtra("messenger", lounge.mMessenger);
    intent.putExtra("name", name);
    ctx.startService(intent);/*  www  .java2s  . c om*/
    ctx.bindService(intent, lounge, Context.BIND_AUTO_CREATE);
    return lounge;
}

From source file:com.duguang.baseanimation.ui.listivew.listviews.ListViewsMainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listviews_main);

    bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mServiceConn,
            Context.BIND_AUTO_CREATE);
}

From source file:com.nokia.example.paymentoneapk.PaymentOneAPKActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    Log.d(TAG, "PaymentOneAPKActivity.onCreate");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*from  www  . ja va2 s  .c o  m*/

    buyButton = (Button) findViewById(R.id.buy);
    buyButton.setEnabled(false);

    buyButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            launchPurchase("android.test.purchased", "inapp", 1234, "");
        }
    });

    final Intent intent = mService.getServiceIntent(this);

    bindService(intent, this, Context.BIND_AUTO_CREATE);
}

From source file:eu.faircode.adblocker.IAB.java

public void bind() {
    Log.i(TAG, "Bind");
    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    context.bindService(serviceIntent, this, Context.BIND_AUTO_CREATE);
}