本文整理匯總了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);
}