Java Code Examples for android.os.RemoteException

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 adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: AbstractPodcastActivity.java

  15 
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 2

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

Source file: AndroidAuthAgentProvider.java

  15 
vote

private void showDebugInfoForAuthAgent(){
  Log.d(TAG,"authAgent=" + authAgent);
  try {
    Log.d(TAG,"authAgent.getIdentities()=" + authAgent.getIdentities());
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
}
 

Example 3

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

Source file: BillingService.java

  15 
vote

/** 
 * Try running the request directly if the service is already connected.
 * @return true if the request ran successfully; false if the serviceis not connected or there was an error when trying to use it
 */
public boolean runIfConnected(){
  if (mService != null) {
    try {
      mRequestId=run();
      if (Consts.DEBUG) {
        Log.d(getClass().getSimpleName(),"request id: " + mRequestId);
      }
      if (mRequestId >= 0) {
        mSentRequests.put(mRequestId,this);
      }
      return true;
    }
 catch (    RemoteException e) {
      onRemoteException(e);
    }
  }
  return false;
}
 

Example 4

From project Android, under directory /AndroidNolesCore/src/io/.

Source file: XmlHandler.java

  15 
vote

/** 
 * Parse the given  {@link XmlPullParser}, turning into a series of {@link ContentProviderOperation} that are immediately applied using thegiven  {@link ContentResolver}.
 */
public void parseAndApply(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  try {
    final ArrayList<ContentProviderOperation> batch=parse(parser,resolver);
    resolver.applyBatch(mAuthority,batch);
  }
 catch (  RemoteException e) {
    LOGW(LOG_TAG,"Problem applying batch operation",e);
  }
catch (  OperationApplicationException e) {
    LOGW(LOG_TAG,"Problem applying batch operation",e);
  }
}
 

Example 5

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

Source file: LiveViewService.java

  15 
vote

public void openInPhone(final String openInPhoneAction) throws RemoteException {
  mCallbackHandler.post(new Runnable(){
    public void run(){
      LiveViewService.this.openInPhone(openInPhoneAction);
    }
  }
);
}
 

Example 6

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

Source file: ChannelSync.java

  15 
vote

/** 
 * Start the channel sync process by sending out fetch requests.
 */
@Override public void start(){
  Cursor cursor=resolver.query(Roster.CONTENT_URI,Roster.PROJECTION_MAP,null,null,null);
  if (cursor.moveToFirst()) {
    while (!cursor.isAfterLast()) {
      String node=cursor.getString(cursor.getColumnIndex(Roster.JID));
      Long lastUpdate=cursor.getLong(cursor.getColumnIndex(Roster.LAST_UPDATED));
      roster.put(node,lastUpdate == null ? 0l : lastUpdate);
      cursor.moveToNext();
    }
  }
  cursor.close();
  PubSub pubsub=new PubSub();
  pubsub.setTo("broadcaster.buddycloud.com");
  SubscriptionsExtension subscription=new SubscriptionsExtension(null);
  pubsub.addExtension(subscription);
  try {
    String fullJid=client.getFullJidByBare(via);
    pubsub.setFrom(fullJid);
    send(pubsub,1);
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
}
 

Example 7

From project android-context, under directory /defunct/.

Source file: ContextProximityActivity.java

  15 
vote

private void refreshAddress(){
  addressAdapter.clear();
  SharedPreferences pref=getSharedPreferences(ContextConstants.PREFS_ADDRESS,0);
  Map<String,String> list=(Map<String,String>)pref.getAll();
  for (  Map.Entry<String,String> entry : list.entrySet()) {
    ContextListItem item=new ContextListItem();
    item.setName(entry.getKey());
    double proximity=0;
    try {
      proximity=mService.proximityToAddress(entry.getValue());
    }
 catch (    RemoteException e) {
      e.printStackTrace();
    }
    item.setValue(String.valueOf(proximity));
    addressAdapter.add(item);
  }
  addressAdapter.notifyDataSetChanged();
}
 

Example 8

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

Source file: BulkCursorNative.java

  15 
vote

public CursorWindow getWindow(int startPos) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IBulkCursor.descriptor);
  data.writeInt(startPos);
  mRemote.transact(GET_CURSOR_WINDOW_TRANSACTION,data,reply,0);
  DatabaseUtils.readExceptionFromParcel(reply);
  CursorWindow window=null;
  if (reply.readInt() == 1) {
    window=CursorWindow.newFromParcel(reply);
  }
  data.recycle();
  reply.recycle();
  return window;
}
 

Example 9

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

Source file: BillingService.java

  15 
vote

/** 
 * Try running the request directly if the service is already connected.
 * @return true if the request ran successfully; false if the service is not connected orthere was an error when trying to use it
 */
public boolean runIfConnected(){
  if (Consts.DEBUG) {
    Log.d(TAG,getClass().getSimpleName());
  }
  if (mService != null) {
    try {
      mRequestId=run();
      if (Consts.DEBUG) {
        Log.d(TAG,"request id: " + mRequestId);
      }
      if (mRequestId >= 0) {
        mSentRequests.put(mRequestId,this);
      }
      return true;
    }
 catch (    RemoteException e) {
      onRemoteException(e);
    }
  }
  return false;
}
 

Example 10

From project android-joedayz, under directory /Proyectos/FBConnectTest/src/com/facebook/android/.

Source file: Facebook.java

  15 
vote

private void refreshToken(){
  Bundle requestData=new Bundle();
  requestData.putString(TOKEN,mAccessToken);
  Message request=Message.obtain();
  request.setData(requestData);
  request.replyTo=messageReceiver;
  try {
    messageSender.send(request);
  }
 catch (  RemoteException e) {
    serviceListener.onError(new Error("Service connection error"));
  }
}
 

Example 11

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

Source file: BatchOperation.java

  15 
vote

public void execute(){
  if (mOperations.size() == 0) {
    return;
  }
  try {
    mResolver.applyBatch(ContactsContract.AUTHORITY,mOperations);
  }
 catch (  final OperationApplicationException e1) {
    Log.e(TAG,"storing contact data failed",e1);
  }
catch (  final RemoteException e2) {
    Log.e(TAG,"storing contact data failed",e2);
  }
  mOperations.clear();
}
 

Example 12

From project android-tether, under directory /facebook/src/com/facebook/android/.

Source file: Facebook.java

  15 
vote

private void refreshToken(){
  Bundle requestData=new Bundle();
  requestData.putString(TOKEN,mAccessToken);
  Message request=Message.obtain();
  request.setData(requestData);
  request.replyTo=messageReceiver;
  try {
    messageSender.send(request);
  }
 catch (  RemoteException e) {
    serviceListener.onError(new Error("Service connection error"));
  }
}
 

Example 13

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

Source file: UserDictionary.java

  15 
vote

/** 
 * Adds a word to the dictionary and makes it persistent.
 * @param word the word to add. If the word is capitalized, then the dictionary willrecognize it as a capitalized word when searched.
 * @param frequency the frequency of occurrence of the word. A frequency of 255 is consideredthe highest.
 * @TODO use a higher or float range for frequency
 */
@Override public synchronized void addWord(final String word,final int frequency){
  if (getRequiresReload())   loadDictionaryAsync();
  if (word.length() >= getMaxWordLength())   return;
  super.addWord(word,frequency);
  final ContentValues values=new ContentValues(5);
  values.put(Words.WORD,word);
  values.put(Words.FREQUENCY,frequency);
  values.put(Words.LOCALE,mLocale);
  values.put(Words.APP_ID,0);
  final ContentResolver contentResolver=getContext().getContentResolver();
  final ContentProviderClient client=contentResolver.acquireContentProviderClient(Words.CONTENT_URI);
  if (null == client)   return;
  new Thread("addWord"){
    @Override public void run(){
      Cursor cursor=null;
      try {
        cursor=client.query(Words.CONTENT_URI,PROJECTION_ADD,"word=? and ((locale IS NULL) or (locale=?))",new String[]{word,mLocale},null);
        if (cursor != null && cursor.moveToFirst()) {
          final String locale=cursor.getString(cursor.getColumnIndex(Words.LOCALE));
          if (locale != null && locale.equals(mLocale.toString())) {
            final long id=cursor.getLong(cursor.getColumnIndex(Words._ID));
            final Uri uri=Uri.withAppendedPath(Words.CONTENT_URI,Long.toString(id));
            client.update(uri,values,null,null);
          }
        }
 else {
          client.insert(Words.CONTENT_URI,values);
        }
      }
 catch (      RemoteException e) {
      }
 finally {
        if (null != cursor)         cursor.close();
        client.release();
      }
    }
  }
.start();
  setRequiresReload(false);
}
 

Example 14

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

Source file: AuthenticationActor.java

  15 
vote

public void disconnect(){
  ServiceConnection c=new ServiceConnection(){
    public void onServiceConnected(    ComponentName className,    IBinder service){
      try {
        IVpnService.Stub.asInterface(service).disconnect();
      }
 catch (      RemoteException e) {
        Log.e(TAG,"disconnect()",e);
        checkStatus();
      }
 finally {
        mContext.unbindService(this);
      }
    }
    public void onServiceDisconnected(    ComponentName className){
      checkStatus();
    }
  }
;
  if (!bindService(c)) {
    checkStatus();
  }
}
 

Example 15

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

Source file: BillingRequest.java

  15 
vote

public long run(IMarketBillingService mService) throws RemoteException {
  final Bundle request=makeRequestBundle();
  addParams(request);
  final Bundle response;
  try {
    response=mService.sendBillingRequest(request);
  }
 catch (  NullPointerException e) {
    Log.e(this.getClass().getSimpleName(),"Known IAB bug. See: http://code.google.com/p/marketbilling/issues/detail?id=25",e);
    return IGNORE_REQUEST_ID;
  }
  if (validateResponse(response)) {
    processOkResponse(response);
    return response.getLong(KEY_REQUEST_ID,IGNORE_REQUEST_ID);
  }
 else {
    return IGNORE_REQUEST_ID;
  }
}
 

Example 16

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

Source file: BatchOperation.java

  15 
vote

public void execute(){
  if (mOperations.size() == 0) {
    return;
  }
  try {
    mResolver.applyBatch(ContactsContract.AUTHORITY,mOperations);
  }
 catch (  final OperationApplicationException e1) {
    Log.e(TAG,"storing contact data failed",e1);
  }
catch (  final RemoteException e2) {
    Log.e(TAG,"storing contact data failed",e2);
  }
  mOperations.clear();
}
 

Example 17

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

Source file: ServerContainer.java

  15 
vote

@Override public void onClick(View v){
  try {
    Log.i("ServerContainer","start TCP server container");
    mService.start();
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
}
 

Example 18

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

Source file: ManageApplications.java

  15 
vote

void init(){
  try {
    mInstallLocation=mPm.getInstallLocation();
  }
 catch (  RemoteException e) {
    Log.e("CanBeOnSdCardChecker","Is Package Manager running?");
    return;
  }
}
 

Example 19

From project android_packages_apps_CellBroadcastReceiver, under directory /src/com/android/cellbroadcastreceiver/.

Source file: CellBroadcastReceiver.java

  15 
vote

/** 
 * @return true if the phone is a CDMA phone type
 */
private static boolean phoneIsCdma(){
  boolean isCdma=false;
  try {
    ITelephony phone=ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
    if (phone != null) {
      isCdma=(phone.getActivePhoneType() == TelephonyManager.PHONE_TYPE_CDMA);
    }
  }
 catch (  RemoteException e) {
    Log.w(TAG,"phone.getActivePhoneType() failed",e);
  }
  return isCdma;
}
 

Example 20

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

Source file: ApplicationActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mPm=IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
  if (mPm == null) {
    Log.wtf(LOG_TAG,"Unable to get PackageManager!");
  }
  setTitle(R.string.application_settings_title_subhead);
  addPreferencesFromResource(R.xml.application_settings);
  PreferenceScreen prefSet=getPreferenceScreen();
  mInstallLocationPref=(ListPreference)prefSet.findPreference(INSTALL_LOCATION_PREF);
  String installLocation="0";
  try {
    installLocation=String.valueOf(mPm.getInstallLocation());
  }
 catch (  RemoteException e) {
    Log.e(LOG_TAG,"Unable to get default install location!",e);
  }
  mInstallLocationPref.setValue(installLocation);
  mInstallLocationPref.setOnPreferenceChangeListener(this);
  mSwitchStoragePref=(CheckBoxPreference)prefSet.findPreference(SWITCH_STORAGE_PREF);
  mSwitchStoragePref.setChecked((SystemProperties.getInt("persist.sys.vold.switchexternal",0) == 1));
  if (SystemProperties.get("ro.vold.switchablepair","").equals("")) {
    mSwitchStoragePref.setSummaryOff(R.string.pref_storage_switch_unavailable);
    mSwitchStoragePref.setEnabled(false);
  }
  mMoveAllAppsPref=(CheckBoxPreference)prefSet.findPreference(MOVE_ALL_APPS_PREF);
  mMoveAllAppsPref.setChecked(Settings.Secure.getInt(getContentResolver(),Settings.Secure.ALLOW_MOVE_ALL_APPS_EXTERNAL,0) == 1);
  mEnableManagement=(CheckBoxPreference)prefSet.findPreference(ENABLE_PERMISSIONS_MANAGEMENT);
  mEnableManagement.setChecked(Settings.Secure.getInt(getContentResolver(),Settings.Secure.ENABLE_PERMISSIONS_MANAGEMENT,getResources().getBoolean(com.android.internal.R.bool.config_enablePermissionsManagement) ? 1 : 0) == 1);
  mEnableManagement.setOnPreferenceChangeListener(this);
}
 

Example 21

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/adapter/.

Source file: AbstractSyncAdapter.java

  15 
vote

/** 
 * We apply the batch of CPO's here.  We synchronize on the service to avoid thread-nasties, and we just return quickly if the service has already been stopped.
 */
private ContentProviderResult[] execute(String authority,ArrayList<ContentProviderOperation> ops) throws RemoteException, OperationApplicationException {
synchronized (mService.getSynchronizer()) {
    if (!mService.isStopped()) {
      if (!ops.isEmpty()) {
        ContentProviderResult[] result=mContentResolver.applyBatch(authority,ops);
        mService.userLog("Results: " + result.length);
        return result;
      }
    }
  }
  return new ContentProviderResult[0];
}
 

Example 22

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: PicasaDataSource.java

  15 
vote

public boolean performOperation(final int operation,final ArrayList<MediaBucket> mediaBuckets,final Object data){
  try {
    if (operation == MediaFeed.OPERATION_DELETE) {
      ContentProviderClient client=mProviderClient;
      for (int i=0, numBuckets=mediaBuckets.size(); i != numBuckets; ++i) {
        MediaBucket bucket=mediaBuckets.get(i);
        ArrayList<MediaItem> items=bucket.mediaItems;
        if (items == null) {
          String albumUri=PicasaContentProvider.ALBUMS_URI + "/" + bucket.mediaSet.mId;
          client.delete(Uri.parse(albumUri),null,null);
        }
 else {
          for (int j=0, numItems=items.size(); j != numItems; ++j) {
            MediaItem item=items.get(j);
            if (item != null) {
              String itemUri=PicasaContentProvider.PHOTOS_URI + "/" + item.mId;
              client.delete(Uri.parse(itemUri),null,null);
            }
          }
        }
      }
    }
    return true;
  }
 catch (  RemoteException e) {
    return false;
  }
}
 

Example 23

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

Source file: NfcDispatcher.java

  15 
vote

/** 
 * Tells the ActivityManager to resume allowing app switches. If the current app called stopAppSwitches() then our startActivity() can be delayed for several seconds. This happens with the default home screen.  As a system service we can override this behavior with resumeAppSwitches().
 */
void resumeAppSwitches(){
  try {
    mIActivityManager.resumeAppSwitches();
  }
 catch (  RemoteException e) {
  }
}
 

Example 24

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

Source file: BluetoothHeadsetService.java

  15 
vote

private void setPriority(BluetoothDevice device,int priority){
  try {
    mBinder.setPriority(device,priority);
  }
 catch (  RemoteException e) {
    Log.e(TAG,"Error while setting priority for: " + device);
  }
}
 

Example 25

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

Source file: UserDictionary.java

  15 
vote

/** 
 * Adds a word to the dictionary and makes it persistent.
 * @param word the word to add. If the word is capitalized, then the dictionary willrecognize it as a capitalized word when searched.
 * @param frequency the frequency of occurrence of the word. A frequency of 255 is consideredthe highest.
 * @TODO use a higher or float range for frequency
 */
@Override public synchronized void addWord(final String word,final int frequency){
  if (getRequiresReload())   loadDictionaryAsync();
  if (word.length() >= getMaxWordLength())   return;
  super.addWord(word,frequency);
  final ContentValues values=new ContentValues(5);
  values.put(Words.WORD,word);
  values.put(Words.FREQUENCY,frequency);
  values.put(Words.LOCALE,mLocale);
  values.put(Words.APP_ID,0);
  final ContentResolver contentResolver=getContext().getContentResolver();
  final ContentProviderClient client=contentResolver.acquireContentProviderClient(Words.CONTENT_URI);
  if (null == client)   return;
  new Thread("addWord"){
    @Override public void run(){
      Cursor cursor=null;
      try {
        cursor=client.query(Words.CONTENT_URI,PROJECTION_ADD,"word=? and ((locale IS NULL) or (locale=?))",new String[]{word,mLocale},null);
        if (cursor != null && cursor.moveToFirst()) {
          final String locale=cursor.getString(cursor.getColumnIndex(Words.LOCALE));
          if (locale != null && locale.equals(mLocale.toString())) {
            final long id=cursor.getLong(cursor.getColumnIndex(Words._ID));
            final Uri uri=Uri.withAppendedPath(Words.CONTENT_URI,Long.toString(id));
            client.update(uri,values,null,null);
          }
        }
 else {
          client.insert(Words.CONTENT_URI,values);
        }
      }
 catch (      RemoteException e) {
      }
 finally {
        if (null != cursor)         cursor.close();
        client.release();
      }
    }
  }
.start();
  setRequiresReload(false);
}
 

Example 26

From project androvoip, under directory /src/org/androvoip/iax2/.

Source file: IAX2Service.java

  15 
vote

public boolean dial(String num) throws RemoteException {
  if (IAX2Service.this.call != null) {
    Log.w("IAX2Service","Can not dial, call in progress");
    return false;
  }
  if (IAX2Service.this.friend == null) {
    Log.w("IAX2Service","Can not dial, not registered");
    return false;
  }
  IAX2Service.this.call=IAX2Service.this.friend.newCall(IAX2Service.this.lastUsername,IAX2Service.this.lastPassword,num,"","");
  return true;
}