List of usage examples for android.os RemoteException printStackTrace
public void printStackTrace()
From source file:org.dmfs.tasks.SettingsListFragment.java
/** * This function is called to save the any modifications made to the displayed list. It retrieves the {@link HashMap} from the adapter of the list and uses * it makes the changes persistent. For this it uses a batch operation provided by {@link ContentResolver}. The operations to be performed in the batch * operation are stored in an {@link ArrayList} of {@link ContentProviderOperation}. * // w w w . j a v a 2s . c o m * @return <code>true</code> if the save operation was successful, <code>false</code> otherwise. */ public boolean saveListState() { HashMap<Long, Boolean> savedPositions = ((VisibleListAdapter) getListAdapter()).getState(); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); for (Long posInt : savedPositions.keySet()) { boolean val = savedPositions.get(posInt); ContentProviderOperation op = ContentProviderOperation .newUpdate(TaskContract.TaskLists.getContentUri(mAuthority)) .withSelection(TaskContract.TaskLists._ID + "=?", new String[] { posInt.toString() }) .withValue(mListCompareColumnName, val ? "1" : "0").build(); ops.add(op); } try { mContext.getContentResolver().applyBatch(mAuthority, ops); } catch (RemoteException e) { e.printStackTrace(); return false; } catch (OperationApplicationException e) { e.printStackTrace(); return false; } return true; }
From source file:com.morlunk.mumbleclient.service.PlumbleService.java
@Override public void onDestroy() { stopForeground(true);//from ww w . j av a 2 s . co m SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences.unregisterOnSharedPreferenceChangeListener(this); unregisterReceiver(mNotificationReceiver); unregisterReceiver(mTalkReceiver); try { getBinder().unregisterObserver(mObserver); } catch (RemoteException e) { e.printStackTrace(); } if (mTTS != null) mTTS.shutdown(); super.onDestroy(); }
From source file:com.morlunk.mumbleclient.service.PlumbleService.java
@Override public void onConnectionEstablished() { super.onConnectionEstablished(); // Restore mute/deafen state if (mSettings.isMuted() || mSettings.isDeafened()) { try {//w w w. j a v a 2 s.co m getBinder().setSelfMuteDeafState(mSettings.isMuted(), mSettings.isDeafened()); } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:com.morlunk.mumbleclient.service.PlumbleService.java
@Override public void onConnectionDisconnected() { super.onConnectionDisconnected(); // Remove overlay if present. mChannelOverlay.hide();/*ww w. j a v a 2 s . c o m*/ mHotCorner.setShown(false); setProximitySensorOn(false); try { if (!getBinder().isReconnecting()) { hideNotification(); // stopSelf(); // Stop manual control of the service's lifecycle. } } catch (RemoteException e) { e.printStackTrace(); } }
From source file:com.github.michalbednarski.intentslab.editor.BundleAdapter.java
private void sandboxBundle(boolean alwaysUpdateKeySet, final Runnable whenDone) { if (mUseSandbox) { // Sandbox already enabled, return if it's still alive, that is, there's no need to reinitialize if (mSandboxedBundle != null && mSandboxedBundle.asBinder().isBinderAlive()) { if (alwaysUpdateKeySet) { try { mKeys = mSandboxedBundle.getKeySet(); mKeysCount = mKeys.length; notifyDataSetChanged(); } catch (RemoteException e) { e.printStackTrace(); }/*from w w w. j av a 2 s . co m*/ } if (whenDone != null) { whenDone.run(); } return; } } else { // Start using sandbox mUseSandbox = true; SandboxManager.refSandbox(); } // If it's being prepared, add to ready callbacks if (mSandboxedBundleReadyCallbacks != null) { if (whenDone != null) { mSandboxedBundleReadyCallbacks.add(whenDone); } return; } // Set flag we're working and add ready callback mSandboxedBundleReadyCallbacks = new ArrayList<Runnable>(); if (whenDone != null) { mSandboxedBundleReadyCallbacks.add(whenDone); } // Initialize sandbox SandboxManager.initSandboxAndRunWhenReady(mOwnerFragment.getActivity(), new Runnable() { @Override public void run() { try { // Wrap bundle // TODO: don't hardcode package name mSandboxedBundle = SandboxManager.getSandbox().sandboxBundle(mBundle, new ClassLoaderDescriptor("com.github.michalbednarski.intentslab.samples")); // Update key set mKeys = mSandboxedBundle.getKeySet(); mKeysCount = mKeys.length; // Notify all callbacks that we're ready for (Runnable readyCallback : mSandboxedBundleReadyCallbacks) { readyCallback.run(); } mSandboxedBundleReadyCallbacks = null; notifyDataSetChanged(); } catch (Exception e) { mSandboxedBundle = null; } } }); }
From source file:org.gateshipone.odyssey.fragments.MyMusicFragment.java
/** * Create a ClickListener for the play button if needed. *///from w w w . j a v a2s . c o m private View.OnClickListener getPlayButtonListener(int tab) { switch (tab) { case 0: case 1: return null; case 2: return new View.OnClickListener() { @Override public void onClick(View v) { // play all tracks on device try { mServiceConnection.getPBS().playAllTracks(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; default: return null; } }
From source file:com.morlunk.mumbleclient.service.PlumbleService.java
@Override public void onCreate() { super.onCreate(); // Register for notification actions IntentFilter notificationIntentFilter = new IntentFilter(); notificationIntentFilter.addAction(BROADCAST_MUTE); notificationIntentFilter.addAction(BROADCAST_DEAFEN); notificationIntentFilter.addAction(BROADCAST_TOGGLE_OVERLAY); registerReceiver(mNotificationReceiver, notificationIntentFilter); registerReceiver(mTalkReceiver, new IntentFilter(BROADCAST_TALK)); try {/*from w w w . j a v a 2 s .co m*/ getBinder().registerObserver(mObserver); } catch (RemoteException e) { e.printStackTrace(); } // Register for preference changes mSettings = Settings.getInstance(this); mPTTSoundEnabled = mSettings.isPttSoundEnabled(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences.registerOnSharedPreferenceChangeListener(this); // Instantiate overlay view mChannelOverlay = new PlumbleOverlay(this); mHotCorner = new PlumbleHotCorner(this, mSettings.getHotCornerGravity(), mHotCornerListener); // Set up TTS if (mSettings.isTextToSpeechEnabled()) mTTS = new TextToSpeech(this, mTTSInitListener); }
From source file:com.teocci.utubinbg.BackgroundAudioService.java
/** * Initializes media sessions and receives media events *///from w w w.j a v a2s . c om private void initMediaSessions() { // Make sure the media player will acquire a wake-lock while playing. If we don't do // that, the CPU might go to sleep while the song is playing, causing playback to stop. // // Remember that to use this, we have to declare the android.permission.WAKE_LOCK // permission in AndroidManifest.xml. mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); ComponentName eventReceiver = new ComponentName(getApplicationContext().getPackageName(), MediaButtonIntentReceiver.class.getName()); PendingIntent buttonReceiverIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(Intent.ACTION_MEDIA_BUTTON), PendingIntent.FLAG_UPDATE_CURRENT); mSession = new MediaSessionCompat(getApplicationContext(), "simple player session", eventReceiver, buttonReceiverIntent); try { mController = new MediaControllerCompat(getApplicationContext(), mSession.getSessionToken()); mSession.setCallback(new MediaSessionCompat.Callback() { @Override public void onPlay() { super.onPlay(); buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE)); } @Override public void onPause() { super.onPause(); pauseVideo(); buildNotification(generateAction(android.R.drawable.ic_media_play, "Play", ACTION_PLAY)); } @Override public void onSkipToNext() { super.onSkipToNext(); if (!isStarting) { playNext(); } buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE)); } @Override public void onSkipToPrevious() { super.onSkipToPrevious(); if (!isStarting) { playPrevious(); } buildNotification(generateAction(android.R.drawable.ic_media_pause, "Pause", ACTION_PAUSE)); } @Override public void onStop() { super.onStop(); stopPlayer(); //remove notification and stop service NotificationManager notificationManager = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(1); Intent intent = new Intent(getApplicationContext(), BackgroundAudioService.class); stopService(intent); } @Override public void onSetRating(RatingCompat rating) { super.onSetRating(rating); } }); } catch (RemoteException re) { re.printStackTrace(); } }
From source file:com.igniva.filemanager.services.CopyService.java
private void publishResults(String a, int p1, int p2, int id, long total, long done, boolean b, boolean move) { if (hash.get(id)) { //notification mBuilder.setProgress(100, p1, false); mBuilder.setOngoing(true);/*w w w .ja v a2 s . co m*/ int title = R.string.copying; if (move) title = R.string.moving; mBuilder.setContentTitle(utils.getString(c, title)); mBuilder.setContentText(new File(a).getName() + " " + utils.readableFileSize(done) + "/" + utils.readableFileSize(total)); int id1 = Integer.parseInt("456" + id); mNotifyManager.notify(id1, mBuilder.build()); if (p1 == 100 || total == 0) { mBuilder.setContentTitle("Copy completed"); if (move) mBuilder.setContentTitle("Move Completed"); mBuilder.setContentText(""); mBuilder.setProgress(0, 0, false); mBuilder.setOngoing(false); mBuilder.setAutoCancel(true); mNotifyManager.notify(id1, mBuilder.build()); publishCompletedResult(id, id1); } //for processviewer DataPackage intent = new DataPackage(); intent.setName(new File(a).getName()); intent.setTotal(total); intent.setDone(done); intent.setId(id); intent.setP1(p1); intent.setP2(p2); intent.setMove(move); intent.setCompleted(b); hash1.put(id, intent); try { if (progressListener != null) { progressListener.onUpdate(intent); if (b) progressListener.refresh(); } } catch (RemoteException e) { e.printStackTrace(); } } else publishCompletedResult(id, Integer.parseInt("456" + id)); }
From source file:ir.aarani.bazaar.billing.BillingProcessor.java
public boolean isSubscriptionUpdateSupported() { // Avoid calling the service again if this value is true if (isSubsUpdateSupported) return true; try {//from w ww .j a v a 2 s . co m int response = billingService.isBillingSupported(Constants.GOOGLE_API_SUBSCRIPTION_CHANGE_VERSION, contextPackageName, Constants.PRODUCT_TYPE_SUBSCRIPTION); isSubsUpdateSupported = response == Constants.BILLING_RESPONSE_RESULT_OK; } catch (RemoteException e) { e.printStackTrace(); } return isSubsUpdateSupported; }