本文整理汇总了Java中android.app.Activity.bindService方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.bindService方法的具体用法?Java Activity.bindService怎么用?Java Activity.bindService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.bindService方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupLocationService
import android.app.Activity; //导入方法依赖的package包/类
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)
// Must be public to use PermissionsDispatcher
public void setupLocationService() {
final String tag="setupLocationService - ";
if (isAdded()) {
final Activity activity=getActivity();
if (activity!=null){
locationServiceConnection = new LocationServiceConnection((OwnLocationReceivedListener) this);
Intent serviceIntent = new Intent(activity,TrackService.class);
activity.startService(serviceIntent);
activity.bindService(new Intent(activity,TrackService.class), locationServiceConnection, Context.BIND_AUTO_CREATE);
} else {
Log.e(TAG,tag+"Activity is null.");
}
}
}
示例2: startService
import android.app.Activity; //导入方法依赖的package包/类
/**
* Bind the activity to a background service and put them into foreground
* state.
*/
private void startService() {
Activity context = cordova.getActivity();
if (isDisabled || isBind)
return;
Intent intent = new Intent(
context, ForegroundService.class);
try {
context.bindService(intent,
connection, Context.BIND_AUTO_CREATE);
fireEvent(Event.ACTIVATE, null);
context.startService(intent);
} catch (Exception e) {
fireEvent(Event.FAILURE, String.format("'%s'", e.getMessage()));
}
isBind = true;
}
示例3: setupNmeaClientService
import android.app.Activity; //导入方法依赖的package包/类
private void setupNmeaClientService() {
final String tag="setupNmeaClientService - ";
if (isAdded()) {
final Activity activity=getActivity();
if (activity!=null) {
nmeaClientServiceConnection = new NmeaClientServiceConnection((ShipReceivedListener) this);
final Intent serviceIntent = new Intent(activity, NmeaClientService.class);
activity.startService(serviceIntent);
activity.bindService(new Intent(activity, NmeaClientService.class), nmeaClientServiceConnection, Context.BIND_AUTO_CREATE);
} else {
Log.e(TAG,tag+"Activity is null.");
}
}
}
示例4: RNOpenXcModule
import android.app.Activity; //导入方法依赖的package包/类
public RNOpenXcModule(ReactApplicationContext reactContext, Activity activity) {
super(reactContext);
this.activity = activity;
if(mVehicleManager == null) {
Intent intent = new Intent(activity, VehicleManager.class);
activity.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
}
示例5: Payment
import android.app.Activity; //导入方法依赖的package包/类
public Payment(Context context){
activity=(Activity)context;
Intent serviceIntent =
new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
activity.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
}
示例6: BluetoothServerManager
import android.app.Activity; //导入方法依赖的package包/类
public BluetoothServerManager(Activity serviceActivity, StatusBarNotificationManager appNotification, List<ServerService> serverServices) {
this.appNotification = appNotification;
this.activity = serviceActivity;
this.serverServices = serverServices;
Intent gattServiceIntent = new Intent(serviceActivity, BluetoothServerService.class);
serviceActivity.bindService(gattServiceIntent, serviceConnection, Activity.BIND_AUTO_CREATE);
}
示例7: BluetoothClientManager
import android.app.Activity; //导入方法依赖的package包/类
public BluetoothClientManager(Activity serviceActivity, StatusBarNotificationManager appNotification) {
this.appNotification = appNotification;
this.serviceActivity = serviceActivity;
Intent gattServiceIntent = new Intent(serviceActivity, BluetoothClientService.class);
serviceActivity.bindService(gattServiceIntent, serviceConnection, Activity.BIND_AUTO_CREATE);
}