当前位置: 首页>>代码示例>>Java>>正文


Java Activity.bindService方法代码示例

本文整理汇总了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.");
        }
    }
}
 
开发者ID:videgro,项目名称:Ships,代码行数:17,代码来源:ShowMapFragment.java

示例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;
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:27,代码来源:BackgroundMode.java

示例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.");
        }
    }
}
 
开发者ID:videgro,项目名称:Ships,代码行数:15,代码来源:ShowMapFragment.java

示例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);
    }
}
 
开发者ID:ozgurchn,项目名称:react-native-openxc,代码行数:9,代码来源:RNOpenXCModule.java

示例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);
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:8,代码来源:Payment.java

示例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);
}
 
开发者ID:masterjc,项目名称:bluewatcher,代码行数:8,代码来源:BluetoothServerManager.java

示例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);
}
 
开发者ID:masterjc,项目名称:bluewatcher,代码行数:7,代码来源:BluetoothClientManager.java


注:本文中的android.app.Activity.bindService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。