android.app.Activity.bindService()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(207)

本文整理了Java中android.app.Activity.bindService()方法的一些代码示例,展示了Activity.bindService()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.bindService()方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:bindService

Activity.bindService介绍

暂无

代码示例

代码示例来源:origin: guardianproject/haven

this.context.bindService(new Intent(context,
    MonitorService.class), mConnection, Context.BIND_ABOVE_CLIENT);

代码示例来源:origin: schwabe/ics-openvpn

private void bindService() {
  Intent icsopenvpnService = new Intent(IOpenVPNAPIService.class.getName());
  icsopenvpnService.setPackage("de.blinkt.openvpn");
  getActivity().bindService(icsopenvpnService, mConnection, Context.BIND_AUTO_CREATE);
}

代码示例来源:origin: willowtreeapps/Hyperion-Android

@Override
public void onActivityResumed(Activity activity) {
  foregroundActivity = activity;
  final ServiceConnection connection = container.getComponent(activity).getServiceConnection();
  foregroundActivity.bindService(
      new Intent(activity, HyperionService.class),
      connection,
      Context.BIND_AUTO_CREATE);
}

代码示例来源:origin: com.uphyca/android-junit4-robolectric

/**
 * @param service
 * @param conn
 * @param flags
 * @return
 * @see android.content.ContextWrapper#bindService(android.content.Intent,
 *      android.content.ServiceConnection, int)
 */
public boolean bindService(Intent service,
              ServiceConnection conn,
              int flags) {
  return mActivity.bindService(service, conn, flags);
}

代码示例来源:origin: lfkdsk/JustWeEngine

public void initWebService() {
  WebServerDefault.init(engine.getApplicationContext());
  // 绑定Service
  engine.bindService(new Intent(engine, WebServerService.class),
      serviceConnection,
      Context.BIND_AUTO_CREATE
  );
}

代码示例来源:origin: lfkdsk/JustWe-WebServer

public void initWebService() {
  WebServerDefault.init(engine.getApplicationContext());
  // 绑定Service
  engine.bindService(new Intent(engine, WebServerService.class),
      serviceConnection,
      Context.BIND_AUTO_CREATE
  );
}

代码示例来源:origin: cyclestreets/android

public static TrackerControl create(final Activity context, final TrackListener listener) {
 Controller control = new Controller(context, listener);
 Intent rService = new Intent(context, RecordingService.class);
 context.bindService(rService, control, Context.BIND_AUTO_CREATE);
 return control;
}

代码示例来源:origin: qiubiteme/android_api_demos

public void onClick(View v) {
    if (((CheckBox)v).isChecked()) {
      if (!mServiceBound) {
        if (mActivity.bindService(new Intent(mActivity, mClz),
            mConnection, Context.BIND_AUTO_CREATE)) {
          mServiceBound = true;
          mStatus.setText("BOUND");
        }
      }
    } else {
      if (mServiceBound) {
        mActivity.unbindService(mConnection);
        mServiceBound = false;
        mStatus.setText("");
      }
    }
  }
};

代码示例来源:origin: NordicSemiconductor/Android-nRF-Beacon

@Override
public void onDeviceSelected(final BluetoothDevice device, final String name) {
  final Activity activity = getActivity();
  final Intent service = new Intent(activity, UpdateService.class);
  service.putExtra(UpdateService.EXTRA_DATA, device);
  activity.startService(service);
  mBinded = true;
  activity.bindService(service, mServiceConnection, 0);
}

代码示例来源:origin: li2/learning-android-open-source

public void onClick(View v) {
    if (((CheckBox)v).isChecked()) {
      if (!mServiceBound) {
        if (mActivity.bindService(new Intent(mActivity, mClz),
            mConnection, Context.BIND_AUTO_CREATE)) {
          mServiceBound = true;
          mStatus.setText("BOUND");
        }
      }
    } else {
      if (mServiceBound) {
        mActivity.unbindService(mConnection);
        mServiceBound = false;
        mStatus.setText("");
      }
    }
  }
};

代码示例来源:origin: trishika/DroidUPnP

@Override
public void resume(Activity activity)
{
  super.resume(activity);
  this.activity = activity;
  // This will start the UPnP service if it wasn't already started
  Log.d(TAG, "Start upnp service");
  activity.bindService(new Intent(activity, UpnpService.class), upnpServiceListener.getServiceConnexion(),
      Context.BIND_AUTO_CREATE);
}

代码示例来源:origin: fire3/sailorcast

@Override
public void resume(Activity activity)
{
  super.resume(activity);
  this.activity = activity;
  // This will start the UPnP service if it wasn't already started
  Log.d(TAG, "Start upnp service");
  activity.bindService(new Intent(activity, UpnpService.class), upnpServiceListener.getServiceConnexion(),
      Context.BIND_AUTO_CREATE);
}

代码示例来源:origin: NordicSemiconductor/Android-nRF-Beacon

@Override
public void onStart() {
  super.onStart();
  // This will connect to the service only if it's already running
  final Activity activity = getActivity();
  final Intent service = new Intent(activity, UpdateService.class);
  mBinded = activity.bindService(service, mServiceConnection, 0);
}

代码示例来源:origin: thuetz/Energize

private void doBindService() {
  this.getActivity().bindService(new Intent(this.getActivity(), MonitorBatteryStateService.class), this.monitorServiceConnection, Context.BIND_AUTO_CREATE);
}

代码示例来源:origin: iqiyi/Neptune

@Override
public boolean bindService(Intent mIntent, ServiceConnection conn, int flags) {
  if (mLoadedApk != null) {
    ComponentFinder.switchToServiceProxy(mLoadedApk, mIntent);
  }
  PluginDebugLog.runtimeLog(TAG, "InstrActivityProxy1 bindService...." + mIntent);
  return super.bindService(mIntent, conn, flags);
}

代码示例来源:origin: thuetz/Energize

private void doBindService() {
  this.getActivity().bindService(new Intent(this.getActivity(), MonitorBatteryStateService.class), this.monitorServiceConnection, Context.BIND_AUTO_CREATE);
}

代码示例来源:origin: sschueller/peertube-android

activity.bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE);

相关文章

Activity类方法