List of usage examples for android.os RemoteException printStackTrace
public void printStackTrace()
From source file:fr.mixit.android.ui.fragments.MemberDetailsFragment.java
protected void refreshMemberData() { if (mIsBound && mServiceReady) { setRefreshMode(true);/* w w w .j av a2 s . co m*/ final Message msg = Message.obtain(null, MixItService.MSG_MEMBER, 0, 0); msg.replyTo = mMessenger; final Bundle b = new Bundle(); b.putInt(MixItService.EXTRA_ID, mMemberId); msg.setData(b); try { mService.send(msg); } catch (final RemoteException e) { e.printStackTrace(); } mIsFirstLoad = false; } }
From source file:com.terracom.mumbleclient.app.QRPushToTalkActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mSettings = Settings.getInstance(this); setTheme(mSettings.getTheme());//from www . j av a2 s . c o m super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setStayAwake(mSettings.shouldStayAwake()); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences.registerOnSharedPreferenceChangeListener(this); mDatabase = new QRPushToTalkSQLiteDatabase(this); // TODO add support for cloud storage mDatabase.open(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerList.setOnItemClickListener(this); mDrawerAdapter = new DrawerAdapter(this, this); mDrawerList.setAdapter(mDrawerAdapter); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View drawerView) { supportInvalidateOptionsMenu(); } @Override public void onDrawerOpened(View drawerView) { supportInvalidateOptionsMenu(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); // Tint logo to theme int iconColor = getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorPrimaryInverse }) .getColor(0, -1); Drawable logo = getResources().getDrawable(R.drawable.ic_home); logo.setColorFilter(iconColor, PorterDuff.Mode.MULTIPLY); getSupportActionBar().setLogo(logo); mConnectingDialog = new ProgressDialog(this); mConnectingDialog.setIndeterminate(true); mConnectingDialog.setCancelable(true); mConnectingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { try { mService.disconnect(); Toast.makeText(QRPushToTalkActivity.this, R.string.cancelled, Toast.LENGTH_SHORT).show(); } catch (RemoteException e) { e.printStackTrace(); } } }); AlertDialog.Builder dadb = new AlertDialog.Builder(this); dadb.setMessage(R.string.disconnectSure); dadb.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { if (mService != null && mService.isConnected()) mService.disconnect(); loadDrawerFragment(DrawerAdapter.ITEM_FAVOURITES); } catch (RemoteException e) { e.printStackTrace(); } } }); dadb.setNegativeButton(android.R.string.cancel, null); mDisconnectPromptBuilder = dadb; if (savedInstanceState == null) { if (getIntent() != null && getIntent().hasExtra(EXTRA_DRAWER_FRAGMENT)) { loadDrawerFragment(getIntent().getIntExtra(EXTRA_DRAWER_FRAGMENT, DrawerAdapter.ITEM_FAVOURITES)); } else { loadDrawerFragment(DrawerAdapter.ITEM_FAVOURITES); } } // If we're given a Mumble URL to show, open up a server edit fragment. if (getIntent() != null && Intent.ACTION_VIEW.equals(getIntent().getAction())) { String url = getIntent().getDataString(); try { Server server = MumbleURLParser.parseURL(url); // Open a dialog prompting the user to add the Mumble server. Bundle args = new Bundle(); args.putBoolean("save", false); args.putParcelable("server", server); ServerEditFragment fragment = (ServerEditFragment) ServerEditFragment.instantiate(this, ServerEditFragment.class.getName(), args); fragment.show(getSupportFragmentManager(), "url_edit"); } catch (MalformedURLException e) { Toast.makeText(this, getString(R.string.mumble_url_parse_failed), Toast.LENGTH_LONG).show(); e.printStackTrace(); } } if (mSettings.isFirstRun()) showSetupWizard(); }
From source file:com.z3r0byte.magistify.DashboardActivity.java
private void getPurchases() { new Thread(new Runnable() { @Override/* w w w . ja va 2 s. c o m*/ public void run() { try { Thread.sleep(500); ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null); int response = ownedItems.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); ArrayList<String> purchaseDataList = ownedItems .getStringArrayList("INAPP_PURCHASE_DATA_LIST"); ArrayList<String> signatureList = ownedItems .getStringArrayList("INAPP_DATA_SIGNATURE_LIST"); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); String sku = ownedSkus.get(i); JSONObject jo = new JSONObject(purchaseData); String token = jo.getString("purchaseToken"); boughtSKU.add(sku); boughtToken.add(token); Log.i(TAG, "run: Purchased item " + i + ": SKU: " + sku + ", purchaseData:" + purchaseData + ", Signature: " + signature); configUtil.setBoolean("disable_ads", false); configUtil.setBoolean("pro_unlocked", false); if (boughtSKU.contains(SKU_FIFTY_CENTS)) { configUtil.setBoolean("disable_ads", true); configUtil.setString("token_fifty_cents", token); } else if (boughtSKU.contains(SKU_ONE_EURO)) { configUtil.setBoolean("disable_ads", true); configUtil.setBoolean("pro_unlocked", true); configUtil.setString("token_one_euro", token); } else if (boughtSKU.contains(SKU_TWO_EURO)) { configUtil.setBoolean("disable_ads", true); configUtil.setBoolean("pro_unlocked", true); configUtil.setString("token_two_euro", token); } else if (boughtSKU.contains(SKU_FIVE_EURO)) { configUtil.setBoolean("disable_ads", true); configUtil.setBoolean("pro_unlocked", true); configUtil.setString("token_five_euro", token); } } } } catch (RemoteException e) { if (mService != null) { unbindService(mServiceConn); } e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } } }).start(); }
From source file:com.dynamixsoftware.printingsample.IntentApiFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.check_premium: new AlertDialog.Builder(requireContext()).setTitle(R.string.check_premium) .setMessage("" + intentApi.checkPremium()).setPositiveButton(R.string.ok, null).show(); break;/*from www . j a v a2s .c o m*/ case R.id.activate_online: final Context appContext = requireContext().getApplicationContext(); intentApi.setLicense("YOUR_ACTIVATION_KEY", new ISetLicenseCallback.Stub() { @Override public void start() { toastInMainThread(appContext, "activate start"); } @Override public void serverCheck() { toastInMainThread(appContext, "activate check server"); } @Override public void finish(final Result arg0) { toastInMainThread(appContext, "activate finish " + (arg0 == Result.OK ? "ok" : "error")); } }); break; case R.id.setup_printer: intentApi.setupCurrentPrinter(); break; case R.id.change_options: intentApi.changePrinterOptions(); break; case R.id.get_current_printer: try { IPrinterInfo printer = intentApi.getCurrentPrinter(); Toast.makeText(requireContext().getApplicationContext(), "current printer " + (printer != null ? printer.getName() : "null"), Toast.LENGTH_LONG) .show(); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_image: intentApi.print(Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), "image/png", "from printing sample"); break; case R.id.print_file: intentApi.print(Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC)), "application/msword", "from printing sample"); break; case R.id.show_file_preview: intentApi.showFilePreview( Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC)), "application/msword", 0); break; case R.id.print_with_your_rendering: try { IDocument.Stub document = new IDocument.Stub() { private int thumbnailWidth; private int thumbnailHeight; @Override public Bitmap renderPageFragment(int arg0, Rect fragment) throws RemoteException { IPrinterInfo printer = intentApi.getCurrentPrinter(); if (printer != null) { Bitmap bitmap = Bitmap.createBitmap(fragment.width(), fragment.height(), Bitmap.Config.ARGB_8888); for (int i = 0; i < 3; i++) try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = false; if (i > 0) { options.inSampleSize = 1 << i; } Bitmap imageBMP = BitmapFactory.decodeStream( new FileInputStream( FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), null, options); Paint p = new Paint(); int imageWidth = 0; int imageHeight = 0; if (imageBMP != null) { imageWidth = imageBMP.getWidth(); imageHeight = imageBMP.getHeight(); } int xDpi = printer.getPrinterContext().getHResolution(); int yDpi = printer.getPrinterContext().getVResolution(); // in dots int paperWidth = printer.getPrinterContext().getPaperWidth() * xDpi / 72; int paperHeight = printer.getPrinterContext().getPaperHeight() * yDpi / 72; float aspectH = (float) imageHeight / (float) paperHeight; float aspectW = (float) imageWidth / (float) paperWidth; aspectH = aspectH > 1 ? 1 / aspectH : aspectH; aspectW = aspectW > 1 ? 1 / aspectW : aspectW; RectF dst = new RectF(0, 0, fragment.width() * aspectW, fragment.height() * aspectH); float sLeft = 0; float sTop = fragment.top * aspectH; float sRight = imageWidth; float sBottom = fragment.top * aspectH + fragment.bottom * aspectH; RectF source = new RectF(sLeft, sTop, sRight, sBottom); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); // move image to actual printing area dst.offsetTo(dst.left - fragment.left, dst.top - fragment.top); Matrix matrix = new Matrix(); matrix.setRectToRect(source, dst, Matrix.ScaleToFit.FILL); canvas.drawBitmap(imageBMP, matrix, p); break; } catch (IOException ex) { ex.printStackTrace(); break; } catch (OutOfMemoryError ex) { if (bitmap != null) { bitmap.recycle(); bitmap = null; } continue; } return bitmap; } else { return null; } } @Override public void initDeviceContext(IPrinterContext printerContext, int thumbnailWidth, int thumbnailHeight) { this.thumbnailWidth = thumbnailWidth; this.thumbnailHeight = thumbnailHeight; } @Override public int getTotalPages() { return 1; } @Override public String getDescription() { return "PrintHand test page"; } @Override public Bitmap getPageThumbnail(int arg0) throws RemoteException { Bitmap bitmap = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.ARGB_8888); for (int i = 0; i < 3; i++) try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = false; if (i > 0) { options.inSampleSize = 1 << i; } Bitmap imageBMP = BitmapFactory.decodeStream( new FileInputStream( FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), null, options); Paint p = new Paint(); int imageWidth = 0; int imageHeight = 0; if (imageBMP != null) { imageWidth = imageBMP.getWidth(); imageHeight = imageBMP.getHeight(); } // default int paperWidth = 2481; int paperHeight = 3507; IPrinterInfo printer = intentApi.getCurrentPrinter(); if (printer != null) { int xDpi = printer.getPrinterContext().getHResolution(); int yDpi = printer.getPrinterContext().getVResolution(); // in dots paperWidth = printer.getPrinterContext().getPaperWidth() * xDpi / 72; paperHeight = printer.getPrinterContext().getPaperHeight() * yDpi / 72; } float aspectW = (float) imageWidth / (float) paperWidth; float aspectH = (float) imageHeight / (float) paperHeight; RectF dst = new RectF(0, 0, thumbnailWidth * aspectW, thumbnailHeight * aspectH); float sLeft = 0; float sTop = 0; float sRight = imageWidth; float sBottom = imageHeight; RectF source = new RectF(sLeft, sTop, sRight, sBottom); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); Matrix matrix = new Matrix(); matrix.setRectToRect(source, dst, Matrix.ScaleToFit.FILL); canvas.drawBitmap(imageBMP, matrix, p); break; } catch (IOException ex) { ex.printStackTrace(); break; } catch (OutOfMemoryError ex) { if (bitmap != null) { bitmap.recycle(); bitmap = null; } continue; } return bitmap; } }; intentApi.print(document); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_with_your_rendering_without_ui: try { IJob.Stub job = new IJob.Stub() { @Override public Bitmap renderPageFragment(int num, Rect fragment) throws RemoteException { IPrinterInfo printer = intentApi.getCurrentPrinter(); if (printer != null) { Bitmap bitmap = Bitmap.createBitmap(fragment.width(), fragment.height(), Bitmap.Config.ARGB_8888); for (int i = 0; i < 3; i++) try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = false; if (i > 0) { options.inSampleSize = 1 << i; } Bitmap imageBMP = BitmapFactory.decodeStream( new FileInputStream( FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), null, options); Paint p = new Paint(); int imageWidth = 0; int imageHeight = 0; if (imageBMP != null) { imageWidth = imageBMP.getWidth(); imageHeight = imageBMP.getHeight(); } int xDpi = printer.getPrinterContext().getHResolution(); int yDpi = printer.getPrinterContext().getVResolution(); // in dots int paperWidth = printer.getPrinterContext().getPaperWidth() * xDpi / 72; int paperHeight = printer.getPrinterContext().getPaperHeight() * yDpi / 72; float aspectH = (float) imageHeight / (float) paperHeight; float aspectW = (float) imageWidth / (float) paperWidth; RectF dst = new RectF(0, 0, fragment.width() * aspectW, fragment.height() * aspectH); float sLeft = 0; float sTop = fragment.top * aspectH; float sRight = imageWidth; float sBottom = fragment.top * aspectH + fragment.bottom * aspectH; RectF source = new RectF(sLeft, sTop, sRight, sBottom); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); // move image to actual printing area dst.offsetTo(dst.left - fragment.left, dst.top - fragment.top); Matrix matrix = new Matrix(); matrix.setRectToRect(source, dst, Matrix.ScaleToFit.FILL); canvas.drawBitmap(imageBMP, matrix, p); break; } catch (IOException ex) { ex.printStackTrace(); break; } catch (OutOfMemoryError ex) { if (bitmap != null) { bitmap.recycle(); bitmap = null; } continue; } return bitmap; } else { return null; } } @Override public int getTotalPages() { return 1; } }; intentApi.print(job, 1); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_image_with_print_hand_rendering_without_ui: try { intentApi.print("PrintingSample", "image/png", Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG))); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.change_image_options: try { List<PrintHandOption> imageOptions = intentApi.getImagesOptions(); changeRandomOption(imageOptions); intentApi.setImagesOptions(imageOptions); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_file_with_print_hand_rendering_without_ui: try { intentApi.print("PrintingSample", "application/ms-word", Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC))); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_protected_file_with_print_hand_rendering_without_ui: try { intentApi.print("PrintingSample", "application/pdf", Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PDF))); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.change_files_options: try { List<PrintHandOption> fileOptions = intentApi.getFilesOptions(); changeRandomOption(fileOptions); intentApi.setFilesOptions(fileOptions); } catch (RemoteException e) { e.printStackTrace(); } break; } }
From source file:com.smithdtyler.prettygoodmusicplayer.NowPlaying.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent originIntent = getIntent();/*from w w w . ja va 2 s. co m*/ if (originIntent.getBooleanExtra("From_Notification", false)) { String artistName = originIntent.getStringExtra(ArtistList.ARTIST_NAME); String artistAbsPath = originIntent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME); if (artistName != null && artistAbsPath != null) { Log.i(TAG, "Now Playing was launched from a notification, setting up its back stack"); // Reference: https://developer.android.com/reference/android/app/TaskStackBuilder.html TaskStackBuilder tsb = TaskStackBuilder.create(this); Intent intent = new Intent(this, ArtistList.class); tsb.addNextIntent(intent); intent = new Intent(this, AlbumList.class); intent.putExtra(ArtistList.ARTIST_NAME, artistName); intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath); tsb.addNextIntent(intent); String albumName = originIntent.getStringExtra(AlbumList.ALBUM_NAME); if (albumName != null) { intent = new Intent(this, SongList.class); intent.putExtra(AlbumList.ALBUM_NAME, albumName); intent.putExtra(ArtistList.ARTIST_NAME, artistName); intent.putExtra(ArtistList.ARTIST_ABS_PATH_NAME, artistAbsPath); tsb.addNextIntent(intent); } intent = new Intent(this, NowPlaying.class); tsb.addNextIntent(intent); tsb.startActivities(); } } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String theme = sharedPref.getString("pref_theme", getString(R.string.light)); String size = sharedPref.getString("pref_text_size", getString(R.string.medium)); Log.i(TAG, "got configured theme " + theme); Log.i(TAG, "got configured size " + size); // These settings were fixed in english for a while, so check for old style settings as well as language specific ones. if (theme.equalsIgnoreCase(getString(R.string.dark)) || theme.equalsIgnoreCase("dark")) { Log.i(TAG, "setting theme to " + theme); if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) { setTheme(R.style.PGMPDarkSmall); } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) { setTheme(R.style.PGMPDarkMedium); } else { setTheme(R.style.PGMPDarkLarge); } } else if (theme.equalsIgnoreCase(getString(R.string.light)) || theme.equalsIgnoreCase("light")) { Log.i(TAG, "setting theme to " + theme); if (size.equalsIgnoreCase(getString(R.string.small)) || size.equalsIgnoreCase("small")) { setTheme(R.style.PGMPLightSmall); } else if (size.equalsIgnoreCase(getString(R.string.medium)) || size.equalsIgnoreCase("medium")) { setTheme(R.style.PGMPLightMedium); } else { setTheme(R.style.PGMPLightLarge); } } boolean fullScreen = sharedPref.getBoolean("pref_full_screen_now_playing", false); currentFullScreen = fullScreen; if (fullScreen) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } else { ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); } setContentView(R.layout.activity_now_playing); if (savedInstanceState == null) { doBindService(true); startPlayingRequired = true; } else { doBindService(false); startPlayingRequired = false; } // Get the message from the intent Intent intent = getIntent(); if (intent.getBooleanExtra(KICKOFF_SONG, false)) { desiredArtistName = intent.getStringExtra(ArtistList.ARTIST_NAME); desiredAlbumName = intent.getStringExtra(AlbumList.ALBUM_NAME); desiredArtistAbsPath = intent.getStringExtra(ArtistList.ARTIST_ABS_PATH_NAME); desiredSongAbsFileNames = intent.getStringArrayExtra(SongList.SONG_ABS_FILE_NAME_LIST); desiredAbsSongFileNamesPosition = intent.getIntExtra(SongList.SONG_ABS_FILE_NAME_LIST_POSITION, 0); desiredSongProgress = intent.getIntExtra(MusicPlaybackService.TRACK_POSITION, 0); Log.d(TAG, "Got song names " + desiredSongAbsFileNames + " position " + desiredAbsSongFileNamesPosition); TextView et = (TextView) findViewById(R.id.artistName); et.setText(desiredArtistName); et = (TextView) findViewById(R.id.albumName); et.setText(desiredAlbumName); } // The song name field will be set when we get our first update update from the service. final ImageButton pause = (ImageButton) findViewById(R.id.playPause); pause.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { playPause(); } }); ImageButton previous = (ImageButton) findViewById(R.id.previous); previous.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { previous(); } }); previous.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { jumpBack(); return true; } }); ImageButton next = (ImageButton) findViewById(R.id.next); next.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { next(); } }); final ImageButton shuffle = (ImageButton) findViewById(R.id.shuffle); shuffle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleShuffle(); } }); final ImageButton jumpback = (ImageButton) findViewById(R.id.jumpback); jumpback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { jumpBack(); } }); SeekBar seekBar = (SeekBar) findViewById(R.id.songProgressBar); seekBar.setEnabled(true); seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { private int requestedProgress; @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { Log.v(TAG, "drag location updated..." + progress); this.requestedProgress = progress; updateSongProgressLabel(progress); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { NowPlaying.this.userDraggingProgress = true; } @Override public void onStopTrackingTouch(SeekBar seekBar) { Message msg = Message.obtain(null, MusicPlaybackService.MSG_SEEK_TO); msg.getData().putInt(MusicPlaybackService.TRACK_POSITION, requestedProgress); try { Log.i(TAG, "Sending a request to seek!"); mService.send(msg); } catch (RemoteException e) { e.printStackTrace(); } NowPlaying.this.userDraggingProgress = false; } }); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.smithdtyler.ACTION_EXIT"); exitReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "Received exit request, shutting down..."); Intent msgIntent = new Intent(getBaseContext(), MusicPlaybackService.class); msgIntent.putExtra("Message", MusicPlaybackService.MSG_STOP_SERVICE); startService(msgIntent); finish(); } }; registerReceiver(exitReceiver, intentFilter); }
From source file:co.beem.project.beem.service.XmppConnectionAdapter.java
/** * {@inheritDoc}/*from ww w . j ava2 s . co m*/ */ @Override public final void connectAsync() throws RemoteException { if (mAdaptee.isConnected() || mAdaptee.isAuthenticated()) return; Thread t = new Thread(new Runnable() { @Override public void run() { try { connectSync(); } catch (RemoteException e) { e.printStackTrace(); } } }); t.start(); }
From source file:org.openbmap.activities.HostActivity.java
/** * Starts wireless tracking.//from w ww . j av a 2s. c om * @return false on error, otherwise true */ public final boolean requestWirelessUpdates() { // TODO check whether services have already been connected (i.e. received MSG_SERVICE_READY signal) Log.d(TAG, "Requesting wireless updates"); try { if (mWirelessServiceManager == null) { Log.w(TAG, "wirelessServiceManager is null. No message will be sent"); return false; } final int session = mDataHelper.getActiveSessionId(); if (session == RadioBeacon.SESSION_NOT_TRACKING) { Log.e(TAG, "Couldn't start tracking, no active session"); return false; } final Bundle aSessionIdBundle = new Bundle(); aSessionIdBundle.putInt(RadioBeacon.MSG_KEY, session); final Message msgWirelessUp = new Message(); msgWirelessUp.what = RadioBeacon.MSG_START_TRACKING; msgWirelessUp.setData(aSessionIdBundle); mWirelessServiceManager.sendAsync(msgWirelessUp); updateUI(); return true; } catch (final RemoteException e) { // service communication failed e.printStackTrace(); return false; } catch (final NumberFormatException e) { e.printStackTrace(); return false; } catch (final Exception e) { e.printStackTrace(); return false; } }
From source file:net.sf.aria2.MainActivity.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { pref.setEnabled(true);//from ww w . j a v a 2 s.c o m serviceLink = IAria2.Stub.asInterface(service); try { serviceLink.setResultReceiver(backLink); pref.setChecked(serviceLink.isRunning()); } catch (RemoteException e) { // likely service process dying right after binding; // pretty much equals to knowledge, that aria2 isn't running e.printStackTrace(); pref.setEnabled(false); pref.setChecked(false); } }
From source file:org.openbmap.activities.HostActivity.java
/** * Starts GPX tracking.//from w w w . j a va 2 s . c o m * @return false on error, otherwise true */ public final boolean requestGpxTracking() { // TODO check whether services have already been connected (i.e. received MSG_SERVICE_READY signal) Log.d(TAG, "Requesting gpx tracking"); try { if (mPositionServiceManager == null) { Log.w(TAG, "gpsPositionServiceManager is null. No message will be sent"); return false; } final int session = mDataHelper.getActiveSessionId(); if (session == RadioBeacon.SESSION_NOT_TRACKING) { Log.e(TAG, "Couldn't start tracking, no active session"); return false; } Log.d(TAG, "Resuming session " + session); final Bundle aSessionIdBundle = new Bundle(); aSessionIdBundle.putInt(RadioBeacon.MSG_KEY, session); final Message msgGpsUp = new Message(); msgGpsUp.what = RadioBeacon.MSG_START_TRACKING; msgGpsUp.setData(aSessionIdBundle); mPositionServiceManager.sendAsync(msgGpsUp); return true; } catch (final RemoteException e) { // service communication failed e.printStackTrace(); return false; } catch (final NumberFormatException e) { e.printStackTrace(); return false; } catch (final Exception e) { e.printStackTrace(); return false; } }
From source file:org.openbmap.activities.HostActivity.java
/** * Starts broadcasting GPS position./*from w ww. j a v a2 s.c o m*/ * @param provider * @return false on error, otherwise true */ public final boolean requestPositionUpdates(final State provider) { // TODO check whether services have already been connected (i.e. received MSG_SERVICE_READY signal) Log.d(TAG, "Requesting position updates"); try { if (mPositionServiceManager == null) { Log.w(TAG, "gpsPositionServiceManager is null. No message will be sent"); return false; } final int session = mDataHelper.getActiveSessionId(); if (session == RadioBeacon.SESSION_NOT_TRACKING) { Log.e(TAG, "Couldn't start tracking, no active session"); return false; } final Bundle aProviderBundle = new Bundle(); aProviderBundle.putString("provider", provider.toString()); final Message msgGpsUp = new Message(); msgGpsUp.what = RadioBeacon.MSG_START_TRACKING; msgGpsUp.setData(aProviderBundle); mPositionServiceManager.sendAsync(msgGpsUp); // update recording indicator //((StatusBar) findViewById(R.id.gpsStatus)).manageRecordingIndicator(true); updateUI(); mSelectedProvider = provider; return true; } catch (final RemoteException e) { // service communication failed e.printStackTrace(); return false; } catch (final NumberFormatException e) { e.printStackTrace(); return false; } catch (final Exception e) { e.printStackTrace(); return false; } }