Java Code Examples for android.os.IBinder

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-database-sqlcipher, under directory /src/net/sqlcipher/.

Source file: CursorWindow.java

  33 
vote

public CursorWindow(Parcel source,int foo){
  super(true);
  IBinder nativeBinder=source.readStrongBinder();
  mStartPos=source.readInt();
  native_init(nativeBinder);
}
 

Example 2

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/deviceinfo/.

Source file: Memory.java

  33 
vote

private synchronized IMountService getMountService(){
  if (mMountService == null) {
    IBinder service=ServiceManager.getService("mount");
    if (service != null) {
      mMountService=IMountService.Stub.asInterface(service);
    }
 else {
      Log.e(TAG,"Can't get mount service");
    }
  }
  return mMountService;
}
 

Example 3

From project Cafe, under directory /testservice/src/com/baidu/cafe/remote/.

Source file: SystemLib.java

  33 
vote

private synchronized IMountService getMountService(){
  if (mMountService == null) {
    IBinder service=ServiceManager.getService("mount");
    if (service != null) {
      mMountService=IMountService.Stub.asInterface(service);
    }
 else {
      Log.print("Can't get mount service");
    }
  }
  return mMountService;
}
 

Example 4

From project android-marvin, under directory /marvin/src/main/java/de/akquinet/android/marvin/actions/.

Source file: PerformAction.java

  32 
vote

private IBinder bindService(Intent serviceIntent,Class<?> serviceClass,int flags,int timeout,TimeUnit timeUnit) throws TimeoutException {
  TemporaryServiceConnection serviceConnection=new TemporaryServiceConnection(timeout,timeUnit);
  instrumentation.getTargetContext().bindService(serviceIntent,serviceConnection,flags);
  IBinder serviceBinder=serviceConnection.getBinderSync();
  if (serviceBinder == null) {
    throw new TimeoutException("Timeout hit (" + timeout + " "+ timeUnit.toString().toLowerCase()+ ") while trying to connect to service"+ serviceClass != null ? " " + serviceClass.getName() : "" + ".");
  }
  serviceConnections.put(serviceBinder,serviceConnection);
  return serviceBinder;
}
 

Example 5

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/compat/.

Source file: InputMethodServiceCompatWrapper.java

  32 
vote

public void showOptionDialogInternal(AlertDialog dialog){
  final IBinder windowToken=KeyboardSwitcher.getInstance().getKeyboardView().getWindowToken();
  if (windowToken == null)   return;
  dialog.setCancelable(true);
  dialog.setCanceledOnTouchOutside(true);
  final Window window=dialog.getWindow();
  final WindowManager.LayoutParams lp=window.getAttributes();
  lp.token=windowToken;
  lp.type=WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
  window.setAttributes(lp);
  window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  mOptionsDialog=dialog;
  dialog.show();
}
 

Example 6

From project android-xbmcremote-sandbox, under directory /src/org/xbmc/android/account/authenticator/.

Source file: AuthenticationService.java

  32 
vote

@Override public IBinder onBind(Intent intent){
  if (Log.isLoggable(TAG,Log.VERBOSE)) {
    Log.v(TAG,"getBinder()...  returning the AccountAuthenticator binder for intent " + intent);
  }
  IBinder ret=null;
  if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) {
    ret=mAuthenticator.getIBinder();
  }
  return ret;
}
 

Example 7

From project AndroidBillingLibrary, under directory /AndroidBillingLibraryTest/src/net/robotmedia/billing/.

Source file: BillingServiceTest.java

  32 
vote

@SmallTest public void testBind(){
  final Intent intent=new Intent();
  intent.setClass(getContext(),BillingService.class);
  final IBinder service=bindService(intent);
  assertNull(service);
}
 

Example 8

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: UIActivity.java

  32 
vote

private void writeRenderEffect(int id){
  try {
    IBinder flinger=ServiceManager.getService("SurfaceFlinger");
    if (flinger != null) {
      Parcel data=Parcel.obtain();
      data.writeInterfaceToken("android.ui.ISurfaceComposer");
      data.writeInt(id);
      flinger.transact(1014,data,null,0);
      data.recycle();
    }
  }
 catch (  RemoteException ex) {
  }
}
 

Example 9

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/compat/.

Source file: InputMethodServiceCompatWrapper.java

  32 
vote

public void showOptionDialogInternal(AlertDialog dialog){
  final IBinder windowToken=KeyboardSwitcher.getInstance().getKeyboardView().getWindowToken();
  if (windowToken == null)   return;
  dialog.setCancelable(true);
  dialog.setCanceledOnTouchOutside(true);
  final Window window=dialog.getWindow();
  final WindowManager.LayoutParams lp=window.getAttributes();
  lp.token=windowToken;
  lp.type=WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
  window.setAttributes(lp);
  window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
  mOptionsDialog=dialog;
  dialog.show();
}
 

Example 10

From project com.juick.android, under directory /src/com/juick/android/.

Source file: AuthenticationService.java

  32 
vote

@Override public IBinder onBind(Intent intent){
  IBinder ret=null;
  if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) {
    ret=getAuthenticator().getIBinder();
  }
  return ret;
}
 

Example 11

From project cornerstone, under directory /frameworks/base/core/java/android/app/.

Source file: ActivityManagerNative.java

  32 
vote

protected IActivityManager create(){
  IBinder b=ServiceManager.getService("activity");
  if (false) {
    Log.v("ActivityManager","default service binder = " + b);
  }
  IActivityManager am=asInterface(b);
  if (false) {
    Log.v("ActivityManager","default service = " + am);
  }
  return am;
}
 

Example 12

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: Term.java

  31 
vote

@Override public void onPause(){
  super.onPause();
  SessionList sessions=mTermSessions;
  TermViewFlipper viewFlipper=mViewFlipper;
  viewFlipper.onPause();
  if (sessions != null) {
    sessions.removeCallback(this);
    WindowListAdapter adapter=mWinListAdapter;
    if (adapter != null) {
      sessions.removeCallback(adapter);
      sessions.removeTitleChangedListener(adapter);
      viewFlipper.removeCallback(adapter);
    }
  }
  if (AndroidCompat.SDK < 5) {
    mBackKeyPressed=false;
  }
  final IBinder token=viewFlipper.getWindowToken();
  new Thread(){
    @Override public void run(){
      InputMethodManager imm=(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(token,0);
    }
  }
.start();
}
 

Example 13

From project AndroidCommon, under directory /src/com/asksven/android/common/privateapiproxies/.

Source file: NetworkQueryProxy.java

  31 
vote

/** 
 * Default cctor
 */
public NetworkQueryProxy(Context context){
  try {
    ClassLoader cl=context.getClassLoader();
    Class networkQueryServiceClassDefinition=cl.loadClass("com.android.phone.NetworkQueryService");
    @SuppressWarnings("rawtypes") Class serviceManagerClass=cl.loadClass("android.os.ServiceManager");
    @SuppressWarnings("rawtypes") Class[] paramTypesGetService=new Class[1];
    paramTypesGetService[0]=String.class;
    @SuppressWarnings("unchecked") Method methodGetService=serviceManagerClass.getMethod("getService",paramTypesGetService);
    Object[] paramsGetService=new Object[1];
    paramsGetService[0]="networkquery";
    IBinder serviceBinder=(IBinder)methodGetService.invoke(serviceManagerClass,paramsGetService);
    context.startService(new Intent(context,networkQueryServiceClassDefinition));
    if (serviceBinder == null) {
      Log.e(TAG,"no binder to networkquery found");
    }
 else {
      Log.e(TAG,"binder to networkquery acquired");
    }
  }
 catch (  Exception e) {
    Log.e("TAG","An exception occured in NetworkQueryProxy(). Message: " + e.getMessage() + ", cause: "+ e.getCause().getMessage());
    m_Instance=null;
  }
}
 

Example 14

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: FileManagerActivity.java

  31 
vote

private void goToDirectoryInEditText(){
  File browseto=new File(mEditDirectory.getText().toString());
  IBinder windowToken=mEditDirectory.getWindowToken();
  if (browseto.equals(currentDirectory)) {
    showDirectoryInput(false);
    hideKeyboard(windowToken,0);
  }
 else {
    if (mHaveShownErrorMessageForFile != null && mHaveShownErrorMessageForFile.equals(browseto)) {
      mHaveShownErrorMessageForFile=null;
      showDirectoryInput(false);
      hideKeyboard(windowToken,0);
    }
 else {
      if (!browseto.exists()) {
        mHaveShownErrorMessageForFile=browseto;
      }
 else {
        showDirectoryInput(false);
        hideKeyboard(windowToken,0);
      }
      browseTo(browseto);
    }
  }
}
 

Example 15

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: BluetoothHeadsetService.java

  31 
vote

@Override public void onCreate(){
  super.onCreate();
  mAdapter=BluetoothAdapter.getDefaultAdapter();
  mPowerManager=(PowerManager)getSystemService(Context.POWER_SERVICE);
  mBtHandsfree=PhoneApp.getInstance().getBluetoothHandsfree();
  mAg=new BluetoothAudioGateway(mAdapter);
  IntentFilter filter=new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
  filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
  filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
  filter.addAction(AudioManager.VOLUME_CHANGED_ACTION);
  filter.addAction(BluetoothDevice.ACTION_UUID);
  registerReceiver(mBluetoothReceiver,filter);
  IBinder b=ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE);
  if (b == null) {
    throw new RuntimeException("Bluetooth service not available");
  }
  mBluetoothService=IBluetooth.Stub.asInterface(b);
  mRemoteHeadsets=new HashMap<BluetoothDevice,BluetoothRemoteHeadset>();
}
 

Example 16

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: AbstractPodcastActivity.java

  29 
vote

@Override public void onServiceConnected(final ComponentName classname,final IBinder obj){
  mService=IMediaPlaybackService.Stub.asInterface(obj);
  try {
    if (Utils.isNotEmpty(mService.getPath())) {
      podcastPlayer.setVisibility(View.VISIBLE);
      updateTrackInfo();
      refreshNow();
      return;
    }
 else {
      podcastPlayer.setVisibility(View.GONE);
    }
  }
 catch (  final RemoteException ex) {
  }
}
 

Example 17

From project agit, under directory /agit/src/main/java/com/madgag/agit/ssh/.

Source file: AndroidAuthAgentProvider.java

  29 
vote

private void bindSshAgentTo(Context context){
  Intent intent=new Intent("org.openintents.ssh.BIND_SSH_AGENT_SERVICE");
  intent.setComponent(preferredAuthAgentComponentNameProvider.get());
  context.bindService(intent,new ServiceConnection(){
    public void onServiceDisconnected(    ComponentName name){
      Log.i(TAG,"onServiceDisconnected() : Lost " + authAgent);
      authAgent=null;
    }
    public void onServiceConnected(    ComponentName name,    IBinder binder){
      Log.i(TAG,"onServiceConnected() : componentName=" + name + " binder="+ binder);
      authAgent=AndroidAuthAgent.Stub.asInterface(binder);
      signalAuthAgentBound();
    }
  }
,BIND_AUTO_CREATE);
  Log.i(TAG,"made request using context " + context + " to bind to the SSH_AGENT_SERVICE");
}
 

Example 18

From project Airports, under directory /src/com/nadmm/airports/billing/.

Source file: BillingService.java

  29 
vote

/** 
 * This is called when we are connected to the MarketBillingService. This runs in the main UI thread.
 */
@Override public void onServiceConnected(ComponentName name,IBinder service){
  if (Consts.DEBUG) {
    Log.d(TAG,"Billing service connected");
  }
  mService=IMarketBillingService.Stub.asInterface(service);
  runPendingRequests();
}
 

Example 19

From project aksunai, under directory /src/org/androidnerds/app/aksunai/ui/.

Source file: ChatActivity.java

  29 
vote

public void onServiceConnected(ComponentName name,IBinder service){
  mManager=((ChatManager.ChatBinder)service).getService();
  if (getIntent().hasExtra("id")) {
    Bundle extras=getIntent().getExtras();
    ServerDetail details=new ServerDetail(ChatActivity.this,extras.getLong("id"));
    boolean found=false;
synchronized (mManager.mConnections) {
      for (      Server s : mManager.mConnections.values()) {
        if (s.mName.equals(details.mName)) {
          found=true;
        }
      }
    }
    if (!found) {
      Log.d(AppConstants.CHAT_TAG,"need to establish a connection.");
      mManager.openServerConnection(ChatActivity.this,details);
    }
  }
  if (AppConstants.DEBUG) {
    Log.d(AppConstants.CHAT_TAG,"Connected to the service.");
  }
  runOnUiThread(updateChatViews);
}
 

Example 20

From project android-bankdroid, under directory /src/com/liato/bankdroid/liveview/.

Source file: LiveViewService.java

  29 
vote

@Override public void onServiceConnected(final ComponentName className,IBinder service){
  Log.d(PluginConstants.LOG_TAG,"Enter LiveViewService.ServiceConnection.onServiceConnected.");
  mLiveView=IPluginServiceV1.Stub.asInterface(service);
  LiveViewCallback lvCallback=new LiveViewCallback();
  try {
    if (mLiveView != null) {
      mPluginId=mLiveView.register(lvCallback,mMenuIcon,mPluginName,false,getPackageName());
      Log.d(PluginConstants.LOG_TAG,"Plugin registered with id: " + mPluginId);
    }
  }
 catch (  RemoteException re) {
    Log.e(PluginConstants.LOG_TAG,"Failed to install plugin. Stop self.");
    stopSelf();
  }
  Log.d(PluginConstants.LOG_TAG,"Plugin registered. mPluginId: " + mPluginId);
}
 

Example 21

From project android-client_1, under directory /src/com/buddycloud/view/.

Source file: BCActivity.java

  29 
vote

/** 
 * Bind to the buddycloud service, if not yet bound or dead.
 */
protected final synchronized void bindBCService(){
  Intent serviceIntent=new Intent(IBuddycloudService.class.getCanonicalName());
  startService(serviceIntent);
  if (connection == null) {
    connection=new ServiceConnection(){
      public void onServiceDisconnected(      ComponentName name){
      }
      public void onServiceConnected(      ComponentName name,      IBinder binder){
        service=IBuddycloudService.Stub.asInterface(binder);
        onBuddycloudServiceBound();
      }
    }
;
  }
  if (service != null) {
    if (service.asBinder().isBinderAlive()) {
      return;
    }
 else {
      service=null;
    }
  }
  bindService(new Intent(IBuddycloudService.class.getName()),connection,Context.BIND_AUTO_CREATE);
}
 

Example 22

From project android-donations-lib, under directory /org_donations/src/org/donations/google/.

Source file: BillingService.java

  29 
vote

/** 
 * This is called when we are connected to the MarketBillingService. This runs in the main UI thread.
 */
public void onServiceConnected(ComponentName name,IBinder service){
  if (Consts.DEBUG) {
    Log.d(TAG,"Billing service connected");
  }
  mService=IMarketBillingService.Stub.asInterface(service);
  runPendingRequests();
}
 

Example 23

From project Android-SyncAdapter-JSON-Server-Example, under directory /src/com/example/android/samplesync/authenticator/.

Source file: AuthenticationService.java

  29 
vote

@Override public IBinder onBind(Intent intent){
  if (Log.isLoggable(TAG,Log.VERBOSE)) {
    Log.v(TAG,"getBinder()...  returning the AccountAuthenticator binder for intent " + intent);
  }
  return mAuthenticator.getIBinder();
}
 

Example 24

From project android-vpn-settings, under directory /src/com/android/settings/vpn/.

Source file: AuthenticationActor.java

  29 
vote

private void connect(final String username,final String password){
  mVpnManager.startVpnService();
  ServiceConnection c=new ServiceConnection(){
    public void onServiceConnected(    ComponentName className,    IBinder service){
      try {
        boolean success=IVpnService.Stub.asInterface(service).connect(mProfile,username,password);
        if (!success) {
          Log.d(TAG,"~~~~~~ connect() failed!");
        }
 else {
          Log.d(TAG,"~~~~~~ connect() succeeded!");
        }
      }
 catch (      Throwable e) {
        Log.e(TAG,"connect()",e);
        broadcastConnectivity(VpnState.IDLE,VpnManager.VPN_ERROR_CONNECTION_FAILED);
      }
 finally {
        mContext.unbindService(this);
      }
    }
    public void onServiceDisconnected(    ComponentName className){
      checkStatus();
    }
  }
;
  if (!bindService(c)) {
    broadcastConnectivity(VpnState.IDLE,VpnManager.VPN_ERROR_CONNECTION_FAILED);
  }
}
 

Example 25

From project AndroidLab, under directory /src/src/de/tubs/ibr/android/ldap/core/activities/.

Source file: EditContactActivity.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder service){
  mBinder=(LDAPService.LDAPBinder)service;
  mBinder.setActivityCallBackHandler(messageHandler);
  mBinder.setRunnable(new ShowDirResultsRunnable(mContext));
  for (  Account acc : AccountManager.get(mContext).getAccounts()) {
    if (acc.name.equals(mSelectedAccount.getName()) && acc.type.equals(mSelectedAccount.getType())) {
      instance=new ServerInstance(AccountManager.get(mContext),acc);
      break;
    }
  }
  mBinder.searchDirs(instance);
}
 

Example 26

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: RecordingActivity.java

  29 
vote

void setListener(){
  Intent rService=new Intent(this,RecordingService.class);
  ServiceConnection sc=new ServiceConnection(){
    public void onServiceDisconnected(    ComponentName name){
    }
    public void onServiceConnected(    ComponentName name,    IBinder service){
      IRecordService rs=(IRecordService)service;
      if (RecordingActivity.this.isRecording) {
        rs.resumeRecording();
      }
 else {
        rs.pauseRecording();
      }
      unbindService(this);
    }
  }
;
  bindService(rService,sc,Context.BIND_AUTO_CREATE);
}
 

Example 27

From project Android_1, under directory /org.eclipse.ecf.android.server/src/org/eclipse/ecf/android/server/.

Source file: ServerContainer.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  mService=IRemoteECFService.Stub.asInterface(service);
  mStartServiceButton.setEnabled(true);
  mCallbackText.setText("Attached.");
  try {
    mService.registerCallback(mCallback);
  }
 catch (  RemoteException e) {
  }
  Toast.makeText(ServerContainer.this,R.string.remote_service_connected,Toast.LENGTH_SHORT).show();
}
 

Example 28

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/.

Source file: NfcService.java

  29 
vote

void _nfcEeClose(int callingPid,IBinder binder) throws IOException {
synchronized (NfcService.this) {
    if (!isNfcEnabledOrShuttingDown()) {
      throw new IOException("NFC adapter is disabled");
    }
    if (mOpenEe == null) {
      throw new IOException("NFC EE closed");
    }
    if (callingPid != -1 && callingPid != mOpenEe.pid) {
      throw new SecurityException("Wrong PID");
    }
    if (mOpenEe.binder != binder) {
      throw new SecurityException("Wrong binder handle");
    }
    binder.unlinkToDeath(mOpenEe,0);
    mDeviceHost.resetTimeouts();
    mSecureElement.doDisconnect(mOpenEe.handle);
    mOpenEe=null;
    applyRouting(true);
  }
}
 

Example 29

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/.

Source file: UpdaterFragment.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder service){
  UpdaterBinder binder=(UpdaterBinder)service;
  mService=binder.getService();
  mBound=true;
  mService.registerUpdaterListener(UpdaterFragment.this);
  if (!mService.isRunning())   mService.getManifest();
}
 

Example 30

From project andstatus, under directory /src/org/andstatus/app/account/.

Source file: AuthenticatorService.java

  29 
vote

@Override public IBinder onBind(Intent intent){
  if (AccountManager.ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction())) {
    return new Authenticator(this).getIBinder();
  }
 else {
    return null;
  }
}
 

Example 31

From project andtweet, under directory /src/com/xorcode/andtweet/.

Source file: AndTweetService.java

  29 
vote

@Override public IBinder onBind(Intent intent){
  if (IAndTweetService.class.getName().equals(intent.getAction())) {
    return mBinder;
  }
  return null;
}
 

Example 32

From project ANE-In-App-Purchase, under directory /NativeAndroid/src/com/freshplanet/inapppurchase/.

Source file: BillingService.java

  29 
vote

/** 
 * This is called when we are connected to the MarketBillingService. This runs in the main UI thread.
 */
public void onServiceConnected(ComponentName name,IBinder service){
  if (Consts.DEBUG) {
    Log.d(TAG,"Billing service connected");
  }
  mService=IMarketBillingService.Stub.asInterface(service);
  runPendingRequests();
}
 

Example 33

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: PersonalDeckPicker.java

  29 
vote

@Override public void onServiceConnected(ComponentName className,IBinder service){
  mDownloadManagerService=IDownloadManagerService.Stub.asInterface(service);
  Log.i(AnkiDroidApp.TAG,"onServiceConnected");
  try {
    mDownloadManagerService.registerPersonalDeckCallback(mCallback);
  }
 catch (  RemoteException e) {
  }
}
 

Example 34

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/.

Source file: AnySoftKeyboard.java

  29 
vote

@Override public AbstractInputMethodImpl onCreateInputMethodInterface(){
  return new InputMethodImpl(){
    @Override public void attachToken(    IBinder token){
      super.attachToken(token);
      mImeToken=token;
    }
  }
;
}
 

Example 35

From project apps-for-android, under directory /BTClickLinkCompete/src/net/clc/bt/.

Source file: Connection.java

  29 
vote

public Connection(Context ctx,OnConnectionServiceReadyListener ocsrListener){
  mOnConnectionServiceReadyListener=ocsrListener;
  mContext=ctx;
  mPackageName=ctx.getPackageName();
  mServiceConnection=new ServiceConnection(){
    public void onServiceConnected(    ComponentName name,    IBinder service){
synchronized (mStartLock) {
        mIconnection=IConnection.Stub.asInterface(service);
        mStarted=true;
        if (mOnConnectionServiceReadyListener != null) {
          mOnConnectionServiceReadyListener.OnConnectionServiceReady();
        }
      }
    }
    public void onServiceDisconnected(    ComponentName name){
synchronized (mStartLock) {
        try {
          mStarted=false;
          mIconnection.unregisterCallback(mPackageName);
          mIconnection.shutdown(mPackageName);
        }
 catch (        RemoteException e) {
          Log.e(TAG,"RemoteException in onServiceDisconnected",e);
        }
        mIconnection=null;
      }
    }
  }
;
  Intent intent=new Intent("com.google.intent.action.BT_ClickLinkCompete_SERVICE");
  intent.addCategory("com.google.intent.category.BT_ClickLinkCompete");
  mContext.bindService(intent,mServiceConnection,Context.BIND_AUTO_CREATE);
}
 

Example 36

From project AsmackService, under directory /src/com/googlecode/asmack/sync/.

Source file: LoginTestThread.java

  29 
vote

/** 
 * Bind to the xmpp service.
 */
private final synchronized void bindService(){
  if (serviceConnection == null) {
    serviceConnection=new ServiceConnection(){
      public void onServiceDisconnected(      ComponentName name){
      }
      public void onServiceConnected(      ComponentName name,      IBinder binder){
        service=IXmppTransportService.Stub.asInterface(binder);
      }
    }
;
  }
  authenticatorActivity.bindService(new Intent(IXmppTransportService.class.getName()),serviceConnection,Context.BIND_AUTO_CREATE);
}
 

Example 37

From project BazaarUtils, under directory /src/com/android/vending/licensing/.

Source file: ILicenseResultListener.java

  29 
vote

/** 
 * Cast an IBinder object into an ILicenseResultListener interface, generating a proxy if needed.
 */
public static com.android.vending.licensing.ILicenseResultListener asInterface(android.os.IBinder obj){
  if ((obj == null)) {
    return null;
  }
  android.os.IInterface iin=(android.os.IInterface)obj.queryLocalInterface(DESCRIPTOR);
  if (((iin != null) && (iin instanceof com.android.vending.licensing.ILicenseResultListener))) {
    return ((com.android.vending.licensing.ILicenseResultListener)iin);
  }
  return new com.android.vending.licensing.ILicenseResultListener.Stub.Proxy(obj);
}
 

Example 38

From project BBC-News-Reader, under directory /src/com/digitallizard/bbcnewsreader/.

Source file: ServiceManager.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  resourceServiceBound=true;
  resourceMessenger=new Messenger(service);
  sendMessageToService(ResourceService.MSG_REGISTER_CLIENT);
  ListIterator<Message> iterator=messageQueue.listIterator();
  while (iterator.hasNext()) {
    sendMessageToService(iterator.next());
  }
  messageQueue.clear();
}
 

Example 39

From project BSPAN---Bluetooth-Sensor-Processing-for-Android, under directory /AndroidSpineServer/src/t2/spine/communication/android/.

Source file: AndroidMessageServer.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  mService=new Messenger(service);
  AndroidSpineServerMainActivity.getInstance().setmService(mService);
  Log.i(TAG,"Service Connected");
  try {
    Message msg=Message.obtain(null,MSG_REGISTER_CLIENT);
    msg.replyTo=mMessenger;
    mService.send(msg);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"Remove exception " + e.toString());
  }
}
 

Example 40

From project btmidi, under directory /BluetoothMidiDemo/src/com/noisepages/nettoyeur/mididemo/.

Source file: PianoActivity.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder service){
  midiService=((BluetoothMidiService.BluetoothMidiBinder)service).getService();
  try {
    midiService.init(observer,receiver);
  }
 catch (  IOException e) {
    toast("MIDI not available");
    finish();
  }
}
 

Example 41

From project ChkBugReport, under directory /examples/testapp/src/com/sonymobile/chkbugreport/testapp/.

Source file: AIDLDeadlock.java

  29 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  System.out.println(">>> onCreate");
  Intent service=new Intent(this,AIDLDeadlockService.class);
  ServiceConnection connection=new ServiceConnection(){
    @Override public void onServiceDisconnected(    ComponentName name){
    }
    @Override public void onServiceConnected(    ComponentName name,    IBinder service){
      mService=IDeadlock.Stub.asInterface(service);
      System.out.println(">>> onService Connected");
      try {
synchronized (LOCK1) {
          mService.setCallback(mCB);
          mService.doStep1();
        }
      }
 catch (      RemoteException e) {
        e.printStackTrace();
      }
    }
  }
;
  bindService(service,connection,BIND_AUTO_CREATE);
}
 

Example 42

From project cicada, under directory /cicada/src/org/cicadasong/cicada/.

Source file: CicadaService.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder binder){
  Log.v(Cicada.TAG,"DeviceService bound");
  service=((DeviceService.DeviceServiceBinder)binder).getService();
  connectionListener=createConnectionListener();
  service.setListener(connectionListener);
  connected=true;
}
 

Example 43

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/screen/movie/.

Source file: CineShowTimeMovieFragment.java

  29 
vote

@Override public void onServiceConnected(ComponentName name,IBinder service){
  serviceMovie=IServiceMovie.Stub.asInterface(service);
  try {
    serviceMovie.registerCallback(m_callback);
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
}
 

Example 44

From project connectbot, under directory /src/sk/vx/connectbot/.

Source file: ConsoleActivity.java

  29 
vote

public void onServiceConnected(ComponentName className,IBinder service){
  bound=((TerminalManager.TerminalBinder)service).getService();
  bound.disconnectHandler=disconnectHandler;
  Log.d(TAG,String.format("Connected to TerminalManager and found bridges.size=%d",bound.bridges.size()));
  bound.setResizeAllowed(true);
  bound.hardKeyboardHidden=(getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES);
  if (bound.getFullScreen() == 0) {
    if (prefs.getBoolean(PreferenceConstants.FULLSCREEN,false))     setFullScreen(FULLSCREEN_ON);
 else     setFullScreen(FULLSCREEN_OFF);
  }
 else   if (fullScreen != bound.getFullScreen())   setFullScreen(bound.getFullScreen());
  flip.removeAllViews();
  final String requestedNickname=(requested != null) ? requested.getFragment() : null;
  int requestedIndex=-1;
  TerminalBridge requestedBridge=bound.getConnectedBridge(requestedNickname);
  if (requestedNickname != null && requestedBridge == null) {
    try {
      Log.d(TAG,String.format("We couldnt find an existing bridge with URI=%s (nickname=%s), so creating one now",requested.toString(),requestedNickname));
      requestedBridge=bound.openConnection(requested);
    }
 catch (    Exception e) {
      Log.e(TAG,"Problem while trying to create new requested bridge from URI",e);
    }
  }
  for (  TerminalBridge bridge : bound.bridges) {
    final int currentIndex=addNewTerminalView(bridge);
    if (bridge == requestedBridge) {
      requestedIndex=currentIndex;
      bound.defaultBridge=bridge;
    }
  }
  if (requestedIndex < 0) {
    requestedIndex=getFlipIndex(bound.defaultBridge);
    if (requestedIndex < 0)     requestedIndex=0;
  }
  setDisplayedTerminal(requestedIndex);
}