當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。