List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:com.inrista.loggliest.Loggly.java
/** * Log an info message and an exception. * @param key Loggly json field/*from w w w.j av a2s.c om*/ * @param msg The log message * @param tr The exception to log */ public static void i(String key, String msg, Throwable tr) { i(key, msg + '\n' + Log.getStackTraceString(tr)); }
From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static void requestAlfrescoLink(AddContentRelatedRepresentation content, final AlfrescoFragment fr, String id, int type) { switch (type) { case TYPE_TASK_ID: fr.getAPI().getTaskService().linkAttachment(id, content, new Callback<RelatedContentRepresentation>() { @Override/*from w ww . j av a2s. c o m*/ public void onResponse(Call<RelatedContentRepresentation> call, Response<RelatedContentRepresentation> response) { // Analytics AnalyticsHelper.reportOperationEvent(fr.getActivity(), AnalyticsManager.CATEGORY_DOCUMENT_MANAGEMENT, AnalyticsManager.ACTION_LINK_CONTENT, response.isSuccessful() ? response.body().getMimeType() : "", 1, !response.isSuccessful()); EventBusManager.getInstance().post(new ContentTransferEvent("-1", ContentTransferSyncAdapter.MODE_SAF_UPLOAD, response.body())); } @Override public void onFailure(Call<RelatedContentRepresentation> call, Throwable error) { if (fr != null) { Snackbar.make(fr.getActivity().findViewById(R.id.left_panel), error.getMessage(), Snackbar.LENGTH_SHORT).show(); } } }); break; case TYPE_PROCESS_ID: fr.getAPI().getProcessService().linkAttachment(id, content, new Callback<RelatedContentRepresentation>() { @Override public void onResponse(Call<RelatedContentRepresentation> call, Response<RelatedContentRepresentation> response) { // Analytics AnalyticsHelper.reportOperationEvent(fr.getActivity(), AnalyticsManager.CATEGORY_DOCUMENT_MANAGEMENT, AnalyticsManager.ACTION_LINK_CONTENT, response.isSuccessful() ? response.body().getMimeType() : "", 1, !response.isSuccessful()); EventBusManager.getInstance().post(new ContentTransferEvent("-1", ContentTransferSyncAdapter.MODE_SAF_UPLOAD, response.body())); } @Override public void onFailure(Call<RelatedContentRepresentation> call, Throwable error) { if (fr != null) { Snackbar.make(fr.getActivity().findViewById(R.id.left_panel), error.getMessage(), Snackbar.LENGTH_SHORT).show(); } } }); break; case TYPE_LINK_ID: fr.getAPI().getContentService().createTemporaryRelatedContent(content, new Callback<RelatedContentRepresentation>() { @Override public void onResponse(Call<RelatedContentRepresentation> call, Response<RelatedContentRepresentation> response) { EventBusManager.getInstance().post(new ContentTransferEvent("-1", ContentTransferSyncAdapter.MODE_SAF_UPLOAD, response.body())); } @Override public void onFailure(Call<RelatedContentRepresentation> call, Throwable error) { if (fr != null) { Snackbar.make(fr.getActivity().findViewById(R.id.left_panel), error.getMessage(), Snackbar.LENGTH_SHORT).show(); } } }); break; default: fr.getAPI().getContentService().createTemporaryRawRelatedContent(content, new Callback<RelatedContentRepresentation>() { @Override public void onResponse(Call<RelatedContentRepresentation> call, Response<RelatedContentRepresentation> response) { EventBusManager.getInstance().post(new ContentTransferEvent("-1", ContentTransferSyncAdapter.MODE_SAF_UPLOAD, response.body())); } @Override public void onFailure(Call<RelatedContentRepresentation> call, Throwable error) { EventBusManager.getInstance() .post(new ContentTransferEvent("-1", new Exception(error.getMessage()))); Log.d("ContentTransferManager", Log.getStackTraceString(error.getCause())); } }); break; } }
From source file:com.dm.material.dashboard.candybar.fragments.RequestFragment.java
private void sendRequest(BillingProcessor billingProcessor) { new AsyncTask<Void, Void, Boolean>() { MaterialDialog dialog;// ww w.ja v a 2 s . co m StringBuilder sb; String zipFile; String productId = ""; String orderId = ""; @Override protected void onPreExecute() { super.onPreExecute(); sb = new StringBuilder(); MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()); builder.content(R.string.request_building); builder.cancelable(false); builder.canceledOnTouchOutside(false); builder.progress(true, 0); builder.progressIndeterminateStyle(true); dialog = builder.build(); dialog.show(); } @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); Database database = new Database(getActivity()); File directory = getActivity().getCacheDir(); sb.append(DeviceHelper.getDeviceInfo(getActivity())); if (Preferences.getPreferences(getActivity()).isPremiumRequest()) { if (billingProcessor == null) return false; TransactionDetails details = billingProcessor.getPurchaseTransactionDetails( Preferences.getPreferences(getActivity()).getPremiumRequestProductId()); if (details != null) { orderId = details.purchaseInfo.purchaseData.orderId; productId = details.purchaseInfo.purchaseData.productId; sb.append("Order Id : ").append(orderId).append("\nProduct Id : ").append(productId) .append("\n"); } } List<Integer> selectedItems = mAdapter.getSelectedItems(); List<String> files = new ArrayList<>(); File appFilter = new File(directory.toString() + "/" + "appfilter.xml"); Writer out = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(appFilter), "UTF8")); for (int i = 0; i < selectedItems.size(); i++) { Request item = mAdapter.getRequest(selectedItems.get(i)); database.addRequest(item.getName(), item.getActivity(), null); mAdapter.setRequested(selectedItems.get(i), true); String string = RequestHelper.writeRequest(item); sb.append(string); String string1 = RequestHelper.writeAppFilter(item); out.append(string1); Bitmap bitmap = DrawableHelper.getHighQualityIcon(getActivity(), item.getPackageName()); String icon = FileHelper.saveIcon(directory, bitmap, item.getName()); if (icon != null) files.add(icon); if (Preferences.getPreferences(getActivity()).isPremiumRequest()) { database.addPremiumRequest(null, orderId, productId, item.getName(), item.getActivity(), null); } } out.flush(); out.close(); files.add(appFilter.toString()); zipFile = directory.toString() + "/" + "icon_request.zip"; FileHelper.createZip(files, zipFile); return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); dialog.dismiss(); if (aBoolean) { String subject = Preferences.getPreferences(getActivity()).isPremiumRequest() ? "Premium Icon Request " : "Icon Request "; subject = subject + getActivity().getResources().getString(R.string.app_name); Request request = new Request(subject, sb.toString(), zipFile, mAdapter.getSelectedItemsSize()); try { RequestListener listener = (RequestListener) getActivity(); listener.onRequestBuilt(request); } catch (Exception ignored) { } mAdapter.resetSelectedItems(); } else { Toast.makeText(getActivity(), R.string.request_build_failed, Toast.LENGTH_LONG).show(); } dialog = null; sb.setLength(0); sb.trimToSize(); } }.execute(); }
From source file:com.asksven.betterbatterystats.StatsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); super.onCreate(savedInstanceState); // HockeyApp/* w w w .j a va 2s .com*/ try { MetricsManager.register(getApplication()); } catch (Exception e) { Log.e(TAG, e.getMessage()); } //Log.i(TAG, "OnCreated called"); setContentView(R.layout.stats); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(getString(R.string.app_name)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayUseLogoEnabled(false); // set debugging if (sharedPrefs.getBoolean("debug_logging", false)) { LogSettings.DEBUG = true; CommonLogSettings.DEBUG = true; } else { LogSettings.DEBUG = false; CommonLogSettings.DEBUG = false; } swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefresh); swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { doRefresh(true); } }); /////////////////////////////////////////////// // check if we have a new release /////////////////////////////////////////////// // if yes do some migration (if required) and show release notes String strLastRelease = sharedPrefs.getString("last_release", "0"); String strCurrentRelease = ""; try { PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0); strCurrentRelease = Integer.toString(pinfo.versionCode); } catch (Exception e) { // nop strCurrentRelease is set to "" } // Grant permissions if they are missing and root is available if (!SysUtils.hasBatteryStatsPermission(this) || !SysUtils.hasDumpsysPermission(this) || !SysUtils.hasPackageUsageStatsPermission(this)) { if ((RootShell.getInstance().isRooted())) { // attempt to set perms using pm-comand Log.i(TAG, "attempting to grant perms with 'pm grant'"); String pkg = this.getPackageName(); RootShell.getInstance().run("pm grant " + pkg + " android.permission.BATTERY_STATS"); RootShell.getInstance().run("pm grant " + pkg + " android.permission.DUMP"); RootShell.getInstance().run("pm grant " + pkg + " android.permission.PACKAGE_USAGE_STATS"); if (SysUtils.hasBatteryStatsPermission(this)) { Log.i(TAG, "succeeded"); } else { Log.i(TAG, "failed"); } } } // Package usage stats were introduced in SDK21 so we need to make the distinction if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // show install as system app screen if root available but perms missing if (!SysUtils.hasBatteryStatsPermission(this) || !SysUtils.hasDumpsysPermission(this) || !SysUtils.hasPackageUsageStatsPermission(this)) { Intent intentSystemApp = new Intent(this, SystemAppActivity.class); this.startActivity(intentSystemApp); } } else { if (!SysUtils.hasBatteryStatsPermission(this) || !SysUtils.hasDumpsysPermission(this)) { Intent intentSystemApp = new Intent(this, SystemAppActivity.class); this.startActivity(intentSystemApp); } } final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // first start if (strLastRelease.equals("0")) { boolean firstLaunch = !prefs.getBoolean("launched", false); if (firstLaunch) { // Save that the app has been launched SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("launched", true); editor.commit(); // start service to persist reference Intent serviceIntent = new Intent(this, WriteUnpluggedReferenceService.class); this.startService(serviceIntent); // refresh widgets Intent intentRefreshWidgets = new Intent(LargeWidgetProvider.WIDGET_UPDATE); this.sendBroadcast(intentRefreshWidgets); } SharedPreferences.Editor updater = sharedPrefs.edit(); updater.putString("last_release", strCurrentRelease); updater.commit(); } else if (!strLastRelease.equals(strCurrentRelease)) { // save the current release to properties so that the dialog won't be shown till next version SharedPreferences.Editor updater = sharedPrefs.edit(); updater.putString("last_release", strCurrentRelease); updater.commit(); // we don't need to delete refs as long as we don't change the database schema // Toast.makeText(this, getString(R.string.info_deleting_refs), Toast.LENGTH_SHORT).show(); // ReferenceStore.deleteAllRefs(this); // Intent i = new Intent(this, WriteBootReferenceService.class); // this.startService(i); // i = new Intent(this, WriteUnpluggedReferenceService.class); // this.startService(i); ChangeLog cl = new ChangeLog(this); cl.getLogDialog().show(); } /////////////////////////////////////////////// // retrieve default selections for spinners // if none were passed /////////////////////////////////////////////// m_iStat = Integer.valueOf(sharedPrefs.getString("default_stat", "0")); m_refFromName = sharedPrefs.getString("default_stat_type", Reference.UNPLUGGED_REF_FILENAME); if (!ReferenceStore.hasReferenceByName(m_refFromName, this)) { m_refFromName = Reference.BOOT_REF_FILENAME; Toast.makeText(this, getString(R.string.info_fallback_to_boot), Toast.LENGTH_SHORT).show(); } if (LogSettings.DEBUG) Log.i(TAG, "onCreate state from preferences: refFrom=" + m_refFromName + " refTo=" + m_refToName); try { // recover any saved state if ((savedInstanceState != null) && (!savedInstanceState.isEmpty())) { m_iStat = (Integer) savedInstanceState.getSerializable("stat"); m_refFromName = (String) savedInstanceState.getSerializable("stattypeFrom"); m_refToName = (String) savedInstanceState.getSerializable("stattypeTo"); if (LogSettings.DEBUG) Log.i(TAG, "onCreate retrieved saved state: refFrom=" + m_refFromName + " refTo=" + m_refToName); } } catch (Exception e) { m_iStat = Integer.valueOf(sharedPrefs.getString("default_stat", "0")); m_refFromName = sharedPrefs.getString("default_stat_type", Reference.UNPLUGGED_REF_FILENAME); Log.e(TAG, "Exception: " + e.getMessage()); DataStorage.LogToFile(LOGFILE, "Exception in onCreate restoring Bundle"); DataStorage.LogToFile(LOGFILE, e.getMessage()); DataStorage.LogToFile(LOGFILE, e.getStackTrace()); Toast.makeText(this, getString(R.string.info_state_recovery_error), Toast.LENGTH_SHORT).show(); } // Handle the case the Activity was called from an intent with paramaters Bundle extras = getIntent().getExtras(); if ((extras != null) && !extras.isEmpty()) { // Override if some values were passed to the intent if (extras.containsKey(StatsActivity.STAT)) m_iStat = extras.getInt(StatsActivity.STAT); if (extras.containsKey(StatsActivity.STAT_TYPE_FROM)) m_refFromName = extras.getString(StatsActivity.STAT_TYPE_FROM); if (extras.containsKey(StatsActivity.STAT_TYPE_TO)) m_refToName = extras.getString(StatsActivity.STAT_TYPE_TO); if (LogSettings.DEBUG) Log.i(TAG, "onCreate state from extra: refFrom=" + m_refFromName + " refTo=" + m_refToName); boolean bCalledFromNotification = extras.getBoolean(StatsActivity.FROM_NOTIFICATION, false); // Clear the notifications that was clicked to call the activity if (bCalledFromNotification) { NotificationManager nM = (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE); nM.cancel(EventWatcherService.NOTFICATION_ID); } } // Spinner for selecting the stat Spinner spinnerStat = (Spinner) findViewById(R.id.spinnerStat); ArrayAdapter spinnerStatAdapter = ArrayAdapter.createFromResource(this, R.array.stats, R.layout.bbs_spinner_layout); //android.R.layout.simple_spinner_item); spinnerStatAdapter.setDropDownViewResource(R.layout.bbs_spinner_dropdown_item); // android.R.layout.simple_spinner_dropdown_item); spinnerStat.setAdapter(spinnerStatAdapter); // setSelection MUST be called after setAdapter spinnerStat.setSelection(m_iStat); spinnerStat.setOnItemSelectedListener(this); /////////////////////////////////////////////// // Spinner for Selecting the Stat type /////////////////////////////////////////////// Spinner spinnerStatType = (Spinner) findViewById(R.id.spinnerStatType); m_spinnerFromAdapter = new ReferencesAdapter(this, R.layout.bbs_spinner_layout); //android.R.layout.simple_spinner_item); m_spinnerFromAdapter.setDropDownViewResource(R.layout.bbs_spinner_dropdown_item); //android.R.layout.simple_spinner_dropdown_item); spinnerStatType.setAdapter(m_spinnerFromAdapter); try { this.setListViewAdapter(); } catch (BatteryInfoUnavailableException e) { Log.e(TAG, "Exception: " + Log.getStackTraceString(e)); Snackbar.make(findViewById(android.R.id.content), R.string.info_service_connection_error, Snackbar.LENGTH_LONG).show(); // Toast.makeText(this, // getString(R.string.info_service_connection_error), // Toast.LENGTH_LONG).show(); } catch (Exception e) { //Log.e(TAG, e.getMessage(), e.fillInStackTrace()); Log.e(TAG, "Exception: " + Log.getStackTraceString(e)); Toast.makeText(this, getString(R.string.info_unknown_stat_error), Toast.LENGTH_LONG).show(); } // setSelection MUST be called after setAdapter spinnerStatType.setSelection(m_spinnerFromAdapter.getPosition(m_refFromName)); spinnerStatType.setOnItemSelectedListener(this); /////////////////////////////////////////////// // Spinner for Selecting the end sample /////////////////////////////////////////////// Spinner spinnerStatSampleEnd = (Spinner) findViewById(R.id.spinnerStatSampleEnd); m_spinnerToAdapter = new ReferencesAdapter(this, R.layout.bbs_spinner_layout); //android.R.layout.simple_spinner_item); m_spinnerToAdapter.setDropDownViewResource(R.layout.bbs_spinner_dropdown_item); //android.R.layout.simple_spinner_dropdown_item); spinnerStatSampleEnd.setVisibility(View.VISIBLE); spinnerStatSampleEnd.setAdapter(m_spinnerToAdapter); // setSelection must be called after setAdapter if ((m_refToName != null) && !m_refToName.equals("")) { int pos = m_spinnerToAdapter.getPosition(m_refToName); spinnerStatSampleEnd.setSelection(pos); } else { spinnerStatSampleEnd.setSelection(m_spinnerToAdapter.getPosition(Reference.CURRENT_REF_FILENAME)); } spinnerStatSampleEnd.setOnItemSelectedListener(this); /////////////////////////////////////////////// // sorting /////////////////////////////////////////////// m_iSorting = 0; // log reference store ReferenceStore.logReferences(this); if (LogSettings.DEBUG) { Log.i(TAG, "onCreate final state: refFrom=" + m_refFromName + " refTo=" + m_refToName); Log.i(TAG, "OnCreated end"); } }
From source file:com.master.metehan.filtereagle.Util.java
public static boolean hasValidFingerprint(Context context) { try {/*from w w w . ja va 2 s . c o m*/ PackageManager pm = context.getPackageManager(); String pkg = context.getPackageName(); PackageInfo info = pm.getPackageInfo(pkg, PackageManager.GET_SIGNATURES); byte[] cert = info.signatures[0].toByteArray(); MessageDigest digest = MessageDigest.getInstance("SHA1"); byte[] bytes = digest.digest(cert); StringBuilder sb = new StringBuilder(); for (byte b : bytes) sb.append(Integer.toString(b & 0xff, 16).toLowerCase()); String calculated = sb.toString(); String expected = context.getString(R.string.fingerprint); return calculated.equals(expected); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); return false; } }
From source file:id.ridon.keude.UpdateService.java
@Override protected void onHandleIntent(Intent intent) { receiver = intent.getParcelableExtra(EXTRA_RECEIVER); String address = intent.getStringExtra(EXTRA_ADDRESS); long startTime = System.currentTimeMillis(); try {/*from www .j a v a2 s . com*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); // See if it's time to actually do anything yet... if (!isScheduledRun()) { Log.d("Keude", "Unscheduled (manually requested) update"); } else if (!verifyIsTimeForScheduledRun()) { return; } // Grab some preliminary information, then we can release the // database while we do all the downloading, etc... List<Repo> repos = RepoProvider.Helper.all(this); // Process each repo... Map<String, App> appsToUpdate = new HashMap<String, App>(); List<Apk> apksToUpdate = new ArrayList<Apk>(); List<Repo> unchangedRepos = new ArrayList<Repo>(); List<Repo> updatedRepos = new ArrayList<Repo>(); List<Repo> disabledRepos = new ArrayList<Repo>(); ArrayList<CharSequence> errorRepos = new ArrayList<CharSequence>(); ArrayList<CharSequence> repoErrors = new ArrayList<CharSequence>(); List<RepoUpdater.RepoUpdateRememberer> repoUpdateRememberers = new ArrayList<RepoUpdater.RepoUpdateRememberer>(); boolean changes = false; for (final Repo repo : repos) { if (!repo.inuse) { disabledRepos.add(repo); continue; } else if (!TextUtils.isEmpty(address) && !repo.address.equals(address)) { unchangedRepos.add(repo); continue; } sendStatus(STATUS_INFO, getString(R.string.status_connecting_to_repo, repo.address)); RepoUpdater updater = RepoUpdater.createUpdaterFor(getBaseContext(), repo); updater.setProgressListener(this); try { updater.update(); if (updater.hasChanged()) { for (final App app : updater.getApps()) { appsToUpdate.put(app.id, app); } apksToUpdate.addAll(updater.getApks()); updatedRepos.add(repo); changes = true; repoUpdateRememberers.add(updater.getRememberer()); } else { unchangedRepos.add(repo); } } catch (RepoUpdater.UpdateException e) { errorRepos.add(repo.address); repoErrors.add(e.getMessage()); Log.e("Keude", "Error updating repository " + repo.address + ": " + e.getMessage()); Log.e("Keude", Log.getStackTraceString(e)); } } if (!changes) { Log.d("Keude", "Not checking app details or compatibility, because all repos were up to date."); } else { sendStatus(STATUS_INFO, getString(R.string.status_checking_compatibility)); List<App> listOfAppsToUpdate = new ArrayList<App>(); listOfAppsToUpdate.addAll(appsToUpdate.values()); calcApkCompatibilityFlags(this, apksToUpdate); // Need to do this BEFORE updating the apks, otherwise when it continually // calls "get existing apks for repo X" then it will be getting the newly // created apks, rather than those from the fresh, juicy index we just processed. removeApksNoLongerInRepo(apksToUpdate, updatedRepos); int totalInsertsUpdates = listOfAppsToUpdate.size() + apksToUpdate.size(); updateOrInsertApps(listOfAppsToUpdate, totalInsertsUpdates, 0); updateOrInsertApks(apksToUpdate, totalInsertsUpdates, listOfAppsToUpdate.size()); removeApksFromRepos(disabledRepos); removeAppsWithoutApks(); // This will sort out the icon urls, compatibility flags. and suggested version // for each app. It used to happen here in Java code, but was moved to SQL when // it became apparant we don't always have enough info (depending on which repos // were updated). AppProvider.Helper.calcDetailsFromIndex(this); notifyContentProviders(); //we only remember the update if everything has gone well for (RepoUpdater.RepoUpdateRememberer rememberer : repoUpdateRememberers) { rememberer.rememberUpdate(); } if (prefs.getBoolean(Preferences.PREF_UPD_NOTIFY, true)) { performUpdateNotification(appsToUpdate.values()); } } Editor e = prefs.edit(); e.putLong(Preferences.PREF_UPD_LAST, System.currentTimeMillis()); e.commit(); if (errorRepos.isEmpty()) { if (changes) { sendStatus(STATUS_COMPLETE_WITH_CHANGES); } else { sendStatus(STATUS_COMPLETE_AND_SAME); } } else { if (updatedRepos.size() + unchangedRepos.size() == 0) { sendRepoErrorStatus(STATUS_ERROR_LOCAL, repoErrors); } else { sendRepoErrorStatus(STATUS_ERROR_LOCAL_SMALL, repoErrors); } } } catch (Exception e) { Log.e("Keude", "Exception during update processing:\n" + Log.getStackTraceString(e)); sendStatus(STATUS_ERROR_GLOBAL, e.getMessage()); } finally { Log.d("Keude", "Update took " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds."); receiver = null; } }
From source file:com.inrista.loggliest.Loggly.java
/** * Log a warning message and an exception. * @param key Loggly json field//from w w w .j av a 2s . c om * @param msg The log message * @param tr The exception to log */ public static void w(String key, String msg, Throwable tr) { w(key, msg + '\n' + Log.getStackTraceString(tr)); }
From source file:hku.fyp14017.blencode.ui.controller.SoundController.java
private void copySoundBackPack(SoundInfo selectedSoundInfo, ArrayList<SoundInfo> soundInfoList, SoundBaseAdapter adapter) {//www. j av a 2 s. c o m try { StorageHandler.getInstance().copySoundFileBackPack(selectedSoundInfo); } catch (IOException ioException) { Log.e(TAG, Log.getStackTraceString(ioException)); } updateBackPackActivity(selectedSoundInfo.getTitle(), selectedSoundInfo.getSoundFileName(), soundInfoList, adapter); }
From source file:biz.bokhorst.xprivacy.Util.java
public static String getXOption(String name) { try {/* w ww . j a v a 2 s.c om*/ Class<?> cSystemProperties = Class.forName("android.os.SystemProperties"); Method spGet = cSystemProperties.getDeclaredMethod("get", String.class); String options = (String) spGet.invoke(null, "xprivacy.options"); Log.w("XPrivacy", "Options=" + options); if (options != null) for (String option : options.split(",")) { String[] nv = option.split("="); if (nv[0].equals(name)) if (nv.length > 1) return nv[1]; else return "true"; } } catch (Throwable ex) { Log.e("XPrivacy", ex.toString() + "\n" + Log.getStackTraceString(ex)); } return null; }
From source file:org.pixmob.freemobile.netstat.SyncServiceTesting.java
private DailyStat computeDailyStat(long date) { long timeOnOrange = 0; long timeOnFreeMobile = 0; long timeOnFreeMobile3G = 0; long timeOnFemtocell = 0; long timeOnFreeMobile4G = 0; if (DEBUG) {//from ww w . j a v a2 s . c o m Log.d(TAG, "Computing statistics for " + DateUtils.formatDate(date)); } Cursor computeStatisticsCursor = null; try { computeStatisticsCursor = getContentResolver().query(Events.CONTENT_URI, new String[] { Events.TIMESTAMP, Events.MOBILE_OPERATOR, Events.MOBILE_NETWORK_TYPE, Events.FEMTOCELL }, Events.TIMESTAMP + ">=? AND " + Events.TIMESTAMP + "<=?", new String[] { String.valueOf(date), String.valueOf(date + 86400 * 1000) }, Events.TIMESTAMP); long t0 = 0; MobileOperator op0 = null; CharArrayBuffer cBuf = new CharArrayBuffer(6); while (computeStatisticsCursor.moveToNext()) { final long t = computeStatisticsCursor.getLong(0); computeStatisticsCursor.copyStringToBuffer(1, cBuf); final MobileOperator op = MobileOperator.fromString(cBuf); final NetworkClass nc = NetworkClass.getNetworkClass(computeStatisticsCursor.getInt(2)); final boolean isFemtocell = computeStatisticsCursor.getInt(3) != 0; if (t0 != 0) { if (op != null && op.equals(op0)) { final long dt = t - t0; if (MobileOperator.ORANGE.equals(op)) { timeOnOrange += dt; } else if (MobileOperator.FREE_MOBILE.equals(op)) { timeOnFreeMobile += dt; if (isFemtocell) { timeOnFemtocell += dt; } else if (NetworkClass.NC_3G.equals(nc)) { timeOnFreeMobile3G += dt; } else if (NetworkClass.NC_4G.equals(nc)) { timeOnFreeMobile4G += dt; } } } } t0 = t; op0 = op; } } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } finally { try { if (computeStatisticsCursor != null) computeStatisticsCursor.close(); } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } } final DailyStat s = new DailyStat(); s.orange = timeOnOrange; s.freeMobile = timeOnFreeMobile; s.freeMobile3G = timeOnFreeMobile3G; s.freeMobile4G = timeOnFreeMobile4G; s.freeMobileFemtocell = timeOnFemtocell; return s; }