List of usage examples for android.os RemoteException printStackTrace
public void printStackTrace()
From source file:com.nxp.ltsm.ltsmclient.LTSMCommunicator.java
/******************************************************* * *Common Exchange method for Exchange with SE and Process LTSM Command * ********************************************************/ private static byte[] exchange(byte[] cApdu, int chnl_id) { String TAG = "LTSMCommunicator:exchange"; Log.i(TAG, "Enter"); byte[] rData = new byte[0]; // byte[] xchangeData = new byte[cApdu.length]; try {/* www .j a v a 2 s. c om*/ cApdu[0] = Utils.adjustCLA(cApdu[0], (byte) chnl_id); Log.i(TAG, "Sending Data : " + Utils.bytArrayToHex(cApdu)); rData = exchangeApdu(cApdu); if (rData.length == 0) { Log.i(TAG, "SE transceive failed "); rData = Utils.createStatusCode(Data.SW_NO_DATA_RECEIVED); } Log.i(TAG, " rData : " + Utils.bytArrayToHex(rData)); } catch (RemoteException e) { closeLogicalChannel(); e.printStackTrace(); } return rData; }
From source file:com.sentaroh.android.TaskAutomation.ActivityTaskStatus.java
private void createTaskListContextMenu(View view, int idx) { ccMenu.addMenuItem(getString(R.string.msgs_status_ccmenu_refresh)) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override/*w w w .j a v a 2 s. co m*/ public void onClick(CharSequence menuTitle) { historyListView.setSelection(0); } }); ccMenu.addMenuItem(getString(R.string.msgs_status_ccmenu_move_top), R.drawable.menu_top) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override public void onClick(CharSequence menuTitle) { historyListView.setSelection(0); } }); ccMenu.addMenuItem(getString(R.string.msgs_status_ccmenu_move_bottom), R.drawable.menu_bottom) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override public void onClick(CharSequence menuTitle) { historyListView.setSelection(historyAdapter.getCount() - 1); } }); ccMenu.addMenuItem(getString(R.string.msgs_status_ccmenu_clear), R.drawable.menu_trash) .setOnClickListener(new CustomContextMenuOnClickListener() { @Override public void onClick(CharSequence menuTitle) { try { svcServer.aidlClearTaskHistory(); historyAdapter.buildList(getTaskHistoryList()); historyAdapter.notifyDataSetChanged(); historyListView.setSelection(historyAdapter.getCount() - 1); } catch (RemoteException e) { e.printStackTrace(); } } }); ccMenu.createMenu(); }
From source file:com.nxp.ltsm.ltsmclient.LTSMCommunicator.java
/******************************************************* * * Opens Logical Channel/* ww w . j a v a2 s.co m*/ * ********************************************************/ private static int ltsmOpenChannel() { String TAG = "LTSMCommunicator:openLogicalChannel"; int status; Log.i(TAG, "Enter"); statusCode = 0; byte[] recvData = new byte[1024]; try { openConnection(); } catch (RemoteException e) { closeLogicalChannel(); e.printStackTrace(); } try { recvData = exchangeApdu(Data.openchannel); } catch (RemoteException e) { closeLogicalChannel(); e.printStackTrace(); } if (recvData == null) { Log.i(TAG, "SE transceive failed "); status = Data.SW_SE_TRANSCEIVE_FAILED; } else if (Utils.getSW(recvData) != Data.SW_NO_ERROR) { statusCode = Utils.getSW(recvData); Log.i(TAG, "Invalid Response"); status = Utils.getSW(recvData); } else { Log.i(TAG, "openLogicalChannel SUCCESS"); channelId[channelCnt] = recvData[recvData.length - 3]; isopened[channelCnt] = 1; Utils.saveArray(channelId, "channelId", context); Utils.saveArray(isopened, "isopened", context); channelCnt = channelCnt + 1; Utils.saveInt(channelCnt, "channelCnt", context); status = Data.SW_NO_ERROR; } Log.i(TAG, "Exit"); return status; }
From source file:org.gateshipone.odyssey.activities.OdysseyMainActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.list_linear_listview && mNowPlayingDragStatus == DRAG_STATUS.DRAGGED_UP) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.context_menu_current_playlist, menu); try {//from ww w. ja va2 s. c o m if (mServiceConnection.getPBS() .getCurrentIndex() == ((AdapterView.AdapterContextMenuInfo) menuInfo).position) { menu.findItem(R.id.view_current_playlist_action_playnext).setVisible(false); } } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:org.computeforcancer.android.PrefsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (Logging.VERBOSE) Log.d(Logging.TAG, "ProjectsFragment onCreateView"); // Inflate the layout for this fragment View layout = inflater.inflate(R.layout.prefs_layout, container, false); lv = (ListView) layout.findViewById(R.id.listview); listAdapter = new PrefsListAdapter(getActivity(), this, R.id.listview, data); lv.setAdapter(listAdapter);//from w w w . ja va 2s . c om final SharedPreferences mSharedPreferences = getContext().getSharedPreferences( "org.computeforcancer.android", Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS); mAutoStart = (SwitchCompat) layout.findViewById(R.id.switchRun); mAutoStart.setChecked(mSharedPreferences.getBoolean(SharedPrefs.AUTO_START, true)); mAutoStart.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { mSharedPreferences.edit().putBoolean(SharedPrefs.AUTO_START, b).commit(); try { BOINCActivity.monitor.setAutostart(b); BOINCActivity.monitor.setRunMode(b ? BOINCDefs.RUN_MODE_AUTO : BOINCDefs.RUN_MODE_NEVER); } catch (RemoteException e) { e.printStackTrace(); } } }); mDailyButton = (AppCompatRadioButton) layout.findViewById(R.id.checkBtnDaily); mDailyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mDailyButton.setChecked(true); mWeeklyButton.setChecked(false); mMonthlyButton.setChecked(false); mSharedPreferences.edit().putLong(SharedPrefs.NOTIFICATION_DELAY, DAY).commit(); } }); mWeeklyButton = (AppCompatRadioButton) layout.findViewById(R.id.checkBtnWeekly); mWeeklyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mDailyButton.setChecked(false); mWeeklyButton.setChecked(true); mMonthlyButton.setChecked(false); mSharedPreferences.edit().putLong(SharedPrefs.NOTIFICATION_DELAY, WEEK).commit(); } }); mMonthlyButton = (AppCompatRadioButton) layout.findViewById(R.id.checkBtnMonthly); mMonthlyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mDailyButton.setChecked(false); mWeeklyButton.setChecked(false); mMonthlyButton.setChecked(true); mSharedPreferences.edit().putLong(SharedPrefs.NOTIFICATION_DELAY, MONTH).commit(); } }); final SwitchCompat notificationSwitch = (SwitchCompat) layout.findViewById(R.id.switchNotifications); notificationSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b) { mDailyButton.setChecked(true); mWeeklyButton.setChecked(false); mMonthlyButton.setChecked(false); mDailyButton.setEnabled(true); mWeeklyButton.setEnabled(true); mMonthlyButton.setEnabled(true); if (mSharedPreferences.getLong(SharedPrefs.NOTIFICATION_DELAY, Long.MAX_VALUE) == Long.MAX_VALUE) { mSharedPreferences.edit().putLong(SharedPrefs.NOTIFICATION_DELAY, DAY).commit(); } } else { mDailyButton.setChecked(true); mWeeklyButton.setChecked(false); mMonthlyButton.setChecked(false); mDailyButton.setEnabled(false); mWeeklyButton.setEnabled(false); mMonthlyButton.setEnabled(false); mSharedPreferences.edit().putLong(SharedPrefs.NOTIFICATION_DELAY, Long.MAX_VALUE).commit(); } } }); if (mSharedPreferences.getLong(SharedPrefs.NOTIFICATION_DELAY, Long.MAX_VALUE) == DAY) { notificationSwitch.setChecked(true); mDailyButton.setChecked(true); mWeeklyButton.setChecked(false); mMonthlyButton.setChecked(false); mDailyButton.setEnabled(true); mWeeklyButton.setEnabled(true); mMonthlyButton.setEnabled(true); } else if (mSharedPreferences.getLong(SharedPrefs.NOTIFICATION_DELAY, Long.MAX_VALUE) == WEEK) { notificationSwitch.setChecked(true); mDailyButton.setChecked(false); mWeeklyButton.setChecked(true); mMonthlyButton.setChecked(false); mDailyButton.setEnabled(true); mWeeklyButton.setEnabled(true); mMonthlyButton.setEnabled(true); } else if (mSharedPreferences.getLong(SharedPrefs.NOTIFICATION_DELAY, Long.MAX_VALUE) == MONTH) { notificationSwitch.setChecked(true); mDailyButton.setChecked(false); mWeeklyButton.setChecked(false); mMonthlyButton.setChecked(true); mDailyButton.setEnabled(true); mWeeklyButton.setEnabled(true); mMonthlyButton.setEnabled(true); } else { notificationSwitch.setChecked(false); mDailyButton.setChecked(true); mWeeklyButton.setChecked(false); mMonthlyButton.setChecked(false); mDailyButton.setEnabled(false); mWeeklyButton.setEnabled(false); mMonthlyButton.setEnabled(false); } return layout; }
From source file:com.dynamixsoftware.printingsample.PrintServiceFragment.java
@Override public void onClick(View v) { final Context appContext = requireContext().getApplicationContext(); switch (v.getId()) { case R.id.set_license: printingSdk.setLicense("YOUR_LICENSE_HERE", new ISetLicenseCallback.Stub() { @Override//from w w w. j a v a 2s.c om public void start() { Toast.makeText(appContext, "set license start", Toast.LENGTH_SHORT).show(); } @Override public void serverCheck() { Toast.makeText(appContext, "set license check server", Toast.LENGTH_SHORT).show(); } @Override public void finish(Result result) { Toast.makeText(appContext, "set license finish " + (result == Result.OK ? "ok" : "error"), Toast.LENGTH_SHORT).show(); } }); break; case R.id.init_current_and_recent_printers: try { printingSdk.initRecentPrinters(new ISetupPrinterListener.Stub() { @Override public void start() { toastInMainThread(appContext, "ISetupPrinterListener start"); } @Override public void libraryPackInstallationProcess(int arg0) { toastInMainThread(appContext, "ISetupPrinterListener libraryPackInstallationProcess " + arg0 + " %"); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "ISetupPrinterListener finish " + arg0.name()); if (arg0.getType().equals(ResultType.ERROR_LIBRARY_PACK_NOT_INSTALLED)) { // printingSdk.setup should be called with forceInstall = true to download required drivers } } }); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.get_current_printer: try { Printer currentPrinter = printingSdk.getCurrentPrinter(); showDialog(getString(R.string.success), "Current printer:\n" + (currentPrinter != null ? currentPrinter.getName() : "null")); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.get_recent_printers: try { List<Printer> recentPrinters = printingSdk.getRecentPrintersList(); String message = ""; for (Printer printer : recentPrinters) message += printer.getName() + "\n"; if (message.length() == 0) message = "No recent printers"; showDialog(getString(R.string.success), message); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.discover_wifi: try { printingSdk.startDiscoverWiFi(new IDiscoverListener.Stub() { @Override public void start() { toastInMainThread(appContext, "IDiscoverListener start"); } @Override public void printerFound(List<Printer> arg0) { toastInMainThread(appContext, "IDiscoverListener printerFound"); discoveredPrinters.clear(); discoveredPrinters.addAll(arg0); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "IDiscoverListener finish " + arg0.name()); } }); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.discover_bluetooth: try { printingSdk.startDiscoverBluetooth(new IDiscoverListener.Stub() { @Override public void start() { toastInMainThread(appContext, "IDiscoverListener start"); } @Override public void printerFound(List<Printer> arg0) { toastInMainThread(appContext, "IDiscoverListener printerFound"); discoveredPrinters.clear(); discoveredPrinters.addAll(arg0); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "IDiscoverListener finish " + arg0.name()); } }); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.discover_google_cloud: try { printingSdk.startDiscoverCloud("YOUR_GOOGLE_ACCOUNT_NAME", new IDiscoverCloudListener.Stub() { @Override public void start() { toastInMainThread(appContext, "IDiscoverCloudListener start"); } @Override public void showAuthorization(Intent arg0) { // Launch Intent arg0 to show authorization activity } @Override public void printerFound(List<Printer> arg0) { toastInMainThread(appContext, "IDiscoverCloudListener printerFound"); discoveredPrinters.clear(); discoveredPrinters.addAll(arg0); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "IDiscoverCloudListener finish " + arg0.name()); } }); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.discover_smb: try { discoverSmb = printingSdk.startDiscoverSmb(new IDiscoverSmbListener.Stub() { @Override public void start() { toastInMainThread(appContext, "IDiscoverSmbListener start"); } @Override public void smbFilesFound(List<SmbFile> arg0) { // Show list of SMB files. This listener is used for navigation. // You should call discoverSmbControl.move(arg0) to change location. } @Override public void showAuthorization() { // You have to ask user for authorization credentials and call discoverSmbControl.login(arg0, arg1); } @Override public void printerFound(List<Printer> arg0) { toastInMainThread(appContext, "IDiscoverSmbListener printerFound"); discoveredPrinters.clear(); discoveredPrinters.addAll(arg0); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "IDiscoverSmbListener finish " + arg0.name()); } }); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.discover_usb: try { printingSdk.startDiscoverUSB(new IDiscoverListener.Stub() { @Override public void start() { toastInMainThread(appContext, "IDiscoverListener start"); } @Override public void printerFound(List<Printer> arg0) { toastInMainThread(appContext, "IDiscoverListener printerFound"); discoveredPrinters.clear(); discoveredPrinters.addAll(arg0); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "IDiscoverListener finish " + arg0.name()); } }); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.find_driver: if (!discoveredPrinters.isEmpty()) { Printer printer = discoveredPrinters.get(0); try { printingSdk.findDrivers(printer, new IFindDriversListener.Stub() { @Override public void start() { toastInMainThread(appContext, "IFindDriversListener start"); } @Override public void finish(List<DriversSearchEntry> arg0) { toastInMainThread(appContext, "IFindDriversListener finish; Found " + arg0.size() + " drivers entries;" + ((arg0.size() == 0) ? "" : "")); driversSearchEntries.clear(); driversSearchEntries.addAll(arg0); } }); } catch (RemoteException e) { e.printStackTrace(); } } else showDialog(getString(R.string.error), "Discover printers first"); break; case R.id.get_drivers: if (!discoveredPrinters.isEmpty()) { Printer printer = discoveredPrinters.get(0); TransportType transportType = printer.getTransportTypes().get(0); if (transportType != null) { try { printingSdk.getDriversList(printer, transportType, new IGetDriversListener.Stub() { @Override public void start() { toastInMainThread(appContext, "IGetDriversListener start"); } @Override public void finish(List<DriverHandleEntry> arg0) { toastInMainThread(appContext, "IGetDriversListener finish"); driverHandleEntries.clear(); driverHandleEntries.addAll(arg0); } }); } catch (RemoteException e) { e.printStackTrace(); } } } else showDialog(getString(R.string.error), "Discover printers first"); break; case R.id.setup_recent_printer: try { List<Printer> printerList = printingSdk.getRecentPrintersList(); if (!printerList.isEmpty()) printingSdk.setup(printerList.get(0), true, new ISetupPrinterListener.Stub() { @Override public void start() { toastInMainThread(appContext, "ISetupPrinterListener start"); } @Override public void libraryPackInstallationProcess(int arg0) { toastInMainThread(appContext, "ISetupPrinterListener libraryPackInstallationProcess " + arg0 + " %"); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "ISetupPrinterListener finish " + arg0.name()); if (arg0.getType().equals(ResultType.ERROR_LIBRARY_PACK_NOT_INSTALLED)) { // printingSdk.setup should be called with forceInstall = true to download required drivers } } }); else showDialog(getString(R.string.error), "No recent printers"); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.setup_discovered_printer: if (!discoveredPrinters.isEmpty()) { if (!driversSearchEntries.isEmpty()) { Printer printer = discoveredPrinters.get(0); DriversSearchEntry driversSearchEntry = driversSearchEntries.get(0); try { printingSdk.setup(printer, driversSearchEntry.getDriverHandlesList().get(0), driversSearchEntry.getTransportType(), false, new ISetupPrinterListener.Stub() { @Override public void start() { toastInMainThread(appContext, "ISetupPrinterListener start"); } @Override public void libraryPackInstallationProcess(int arg0) { toastInMainThread(appContext, "ISetupPrinterListener libraryPackInstallationProcess " + arg0 + " %"); } @Override public void finish(Result arg0) { toastInMainThread(appContext, "ISetupPrinterListener finish " + arg0.name()); if (arg0.getType().equals(ResultType.ERROR_LIBRARY_PACK_NOT_INSTALLED)) { // printingSdk.setup should be called with forceInstall = true to download required drivers } } }); } catch (RemoteException e) { e.printStackTrace(); } } else showDialog(getString(R.string.error), "Find driver first"); } else showDialog(getString(R.string.error), "Discover printers first"); break; case R.id.change_options: try { Printer currentPrinter = printingSdk.getCurrentPrinter(); if (currentPrinter != null) { List<PrinterOption> options = currentPrinter.getOptions(); if (options.size() > 0) { Random random = new Random(); PrinterOption option = options.get(random.nextInt(options.size())); PrinterOptionValue currentValue = option.getOptionValue(); List<PrinterOptionValue> valuesList = option.getOptionValueList(); PrinterOptionValue newValue = valuesList.get(random.nextInt(valuesList.size())); printingSdk.setCurrentPrinterOptionValue(option, newValue); Toast.makeText(requireContext().getApplicationContext(), "option " + option.getName() + " changed from " + currentValue + " to " + newValue, Toast.LENGTH_LONG).show(); } } else showDialog(getString(R.string.error), "Setup printer first"); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_image: try { if (printingSdk.getCurrentPrinter() != null) { List<IPage> pages = new ArrayList<>(); pages.add(new IPage() { @Override public Bitmap getBitmapFragment(Rect fragment) { Printer printer = null; try { printer = printingSdk.getCurrentPrinter(); } catch (RemoteException e) { e.printStackTrace(); } 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.getContext().getHResolution(); int yDpi = printer.getContext().getVResolution(); // in dots int paperWidth = printer.getContext().getPaperWidth() * xDpi / 72; int paperHeight = printer.getContext().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; } }); try { printingSdk.print(pages, 1, new IPrintListener.Stub() { @Override public void startingPrintJob() { toastInMainThread(appContext, "IPrintListener startingPrintJob"); } @Override public void start() { toastInMainThread(appContext, "IPrintListener start"); } @Override public void sendingPage(int arg0, int arg1) { toastInMainThread(appContext, "IPrintListener sendingPage " + arg0 + "; progress " + arg1 + "%"); } @Override public void preparePage(int arg0) { toastInMainThread(appContext, "IPrintListener preparePage " + arg0); } @Override public boolean needCancel() { toastInMainThread(appContext, "IPrintListener needCancel"); // Return false if cancel needed. return false; } @Override public void finishingPrintJob() { toastInMainThread(appContext, "IPrintListener finishingPrintJob"); } @Override public void finish(Result arg0, int arg1, int arg2) { toastInMainThread(appContext, "IPrintListener finish Result " + arg0 + "; Result type " + arg0.getType() + "; Total pages " + arg1 + "; Pages sent " + arg2); } }); } catch (RemoteException e) { e.printStackTrace(); } } else showDialog(getString(R.string.error), "You must setup printer before print"); } catch (RemoteException e) { e.printStackTrace(); } break; } }
From source file:org.gege.caldavsyncadapter.caldav.entities.CalendarEvent.java
/** * updates the attendees from a calendarEvent to its androidEvent. * the calendarEvent has to know its androidEvent via {@link CalendarEvent#setAndroidEventUri(Uri)} * @param provider/*www . j a v a 2 s . c o m*/ * @return * @see SyncAdapter#updateAndroidEvent(ContentProviderClient, Account, AndroidEvent, CalendarEvent) */ private boolean updateAndroidAttendees() { boolean Result = false; try { String mSelectionClause = "(" + Attendees.EVENT_ID + " = ?)"; String[] mSelectionArgs = { Long.toString(ContentUris.parseId(this.getAndroidEventUri())) }; int RowDelete; RowDelete = this.mProvider.delete(Attendees.CONTENT_URI, mSelectionClause, mSelectionArgs); Log.d(TAG, "Attendees Deleted:" + String.valueOf(RowDelete)); java.util.ArrayList<ContentValues> AttendeeList = this.getAttandees(); for (ContentValues Attendee : AttendeeList) { this.mProvider.insert(Attendees.CONTENT_URI, Attendee); } Log.d(TAG, "Attendees Inserted:" + String.valueOf(AttendeeList.size())); Result = true; } catch (RemoteException e) { e.printStackTrace(); } return Result; }
From source file:org.gege.caldavsyncadapter.caldav.entities.CalendarEvent.java
/** * update the reminders from a calendarEvent to its androidEvent. * the calendarEvent has to know its androidEvent via {@link CalendarEvent#setAndroidEventUri(Uri)} * @param provider/*from w w w . ja va 2 s . co m*/ * @return * @see SyncAdapter#updateAndroidEvent(ContentProviderClient, Account, AndroidEvent, CalendarEvent) */ private boolean updateAndroidReminder() { boolean Result = false; try { String mSelectionClause = "(" + Reminders.EVENT_ID + " = ?)"; String[] mSelectionArgs = { Long.toString(ContentUris.parseId(this.getAndroidEventUri())) }; int RowDelete; RowDelete = this.mProvider.delete(Reminders.CONTENT_URI, mSelectionClause, mSelectionArgs); Log.d(TAG, "Reminders Deleted:" + String.valueOf(RowDelete)); Uri ReminderUri; java.util.ArrayList<ContentValues> ReminderList = this.getReminders(); for (ContentValues Reminder : ReminderList) { ReminderUri = this.mProvider.insert(Reminders.CONTENT_URI, Reminder); System.out.println(ReminderUri); } Log.d(TAG, "Reminders Inserted:" + String.valueOf(ReminderList.size())); Result = true; } catch (RemoteException e) { e.printStackTrace(); } return Result; }
From source file:com.voiceblue.phone.ui.SipHome.java
@Override public void onOTAConfigMessageReceived(final OTAConfigMessage message) { if (onForeground && message.isRegister()) { try {/* w w w.j a v a2s. c o m*/ // do not re-register from outside siphome to avoid restarting the service // If it fails, then go outside using OTAConfigService class mSipService.reAddAllAccounts(); return; } catch (RemoteException e) { e.printStackTrace(); } } if (!message.isReloadConfig()) { OTAConfigService.processOTAConfigMessageReceived(message, mSipService, SipHome.this); return; } runOnUiThread(new Thread(new Runnable() { @Override public void run() { if (!onForeground) { // not visible. Just mark for conf reload on next restart SipConfigManager.setPreferenceStringValue(SipHome.this, OTAConfig.RELOAD_CONFIG_KEY, "yes"); return; } AlertDialog.Builder builder = new AlertDialog.Builder(SipHome.this); builder.setMessage(getString(R.string.voiceblue_config_changed_msg)) .setTitle(getString(R.string.voiceblue_config_changed_title)); builder.setPositiveButton("Ok", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { OTAConfigService.processOTAConfigMessageReceived(message, mSipService, SipHome.this); } }); builder.create().show(); } })); }
From source file:org.kontalk.billing.GoogleBillingService.java
/** * Starts the setup process. This will start up the setup process asynchronously. * You will be notified through the listener when the setup process is complete. * This method is safe to call from a UI thread. * * @param listener The listener to notify when the setup process is complete. *//*from ww w.j ava2 s .co m*/ public void startSetup(final OnBillingSetupFinishedListener listener) { // If already set up, can't do it again. checkNotDisposed(); if (mSetupDone) throw new IllegalStateException("IAB helper is already set up."); // Connection to IAB service logDebug("Starting in-app billing setup."); mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { logDebug("Billing service disconnected."); mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { if (mDisposed) return; logDebug("Billing service connected."); mService = IInAppBillingService.Stub.asInterface(service); String packageName = mContext.getPackageName(); try { logDebug("Checking for in-app billing 3 support."); // check for in-app billing v3 support int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP); if (response != BILLING_RESPONSE_RESULT_OK) { if (listener != null) listener.onSetupFinished( new BillingResult(response, "Error checking for billing v3 support.")); // if in-app purchases aren't supported, neither are subscriptions. mSubscriptionsSupported = false; return; } logDebug("In-app billing version 3 supported for " + packageName); // check for v3 subscriptions support response = mService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Subscriptions AVAILABLE."); mSubscriptionsSupported = true; } else { logDebug("Subscriptions NOT AVAILABLE. Response: " + response); } mSetupDone = true; } catch (RemoteException e) { if (listener != null) { listener.onSetupFinished(new BillingResult(IABHELPER_REMOTE_EXCEPTION, "RemoteException while setting up in-app billing.")); } e.printStackTrace(); return; } if (listener != null) { listener.onSetupFinished(new BillingResult(BILLING_RESPONSE_RESULT_OK, "Setup successful.")); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); List<ResolveInfo> services = mContext.getPackageManager().queryIntentServices(serviceIntent, 0); if (services != null && !services.isEmpty()) { // service available to handle that Intent mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else { // no service available to handle that Intent if (listener != null) { listener.onSetupFinished(new BillingResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, "Billing service unavailable on device.")); } } }