List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:hku.fyp14017.blencode.ui.controller.SoundController.java
public SoundInfo copySound(SoundInfo selectedSoundInfo, ArrayList<SoundInfo> soundInfoList, SoundBaseAdapter adapter) {/* w w w . j av a 2s . co m*/ try { StorageHandler.getInstance().copySoundFile(selectedSoundInfo.getAbsolutePath()); } catch (IOException ioException) { Log.e(TAG, Log.getStackTraceString(ioException)); } return updateSoundAdapter(selectedSoundInfo.getTitle(), selectedSoundInfo.getSoundFileName(), soundInfoList, adapter); }
From source file:com.morphoss.acal.service.connector.AcalRequestor.java
private String md5(String in) { // Create MD5 Hash MessageDigest digest;//from w w w .j a v a 2 s .c o m try { digest = java.security.MessageDigest.getInstance("MD5"); digest.update(in.getBytes()); return StaticHelpers.toHexString(digest.digest()); } catch (NoSuchAlgorithmException e) { Log.e(TAG, e.getMessage()); Log.println(Constants.LOGV, TAG, Log.getStackTraceString(e)); } return ""; }
From source file:com.inrista.loggliest.Loggly.java
/** * Log an error message and an exception. * @param key Loggly json field/*from ww w . ja v a 2 s .co m*/ * @param msg The log message * @param tr The exception to log */ public static void e(String key, String msg, Throwable tr) { e(key, msg + '\n' + Log.getStackTraceString(tr)); }
From source file:net.olejon.mdapp.NotesEditActivity.java
private void getMedications() { try {/*from w w w .j a v a 2 s .c o m*/ int medicationsJsonArrayLength = mPatientMedicationsJsonArray.length(); if (medicationsJsonArrayLength == 0) { mPatientMedicationsTextView.setVisibility(View.GONE); } else { mPatientMedicationsTextView.setVisibility(View.VISIBLE); final ArrayList<String> medicationsNamesArrayList = new ArrayList<>(); final ArrayList<String> medicationsManufacturersArrayList = new ArrayList<>(); final String[] medicationsNamesStringArrayList = new String[medicationsJsonArrayLength + 2]; medicationsNamesStringArrayList[0] = getString(R.string.notes_edit_medications_dialog_interactions); medicationsNamesStringArrayList[1] = getString(R.string.notes_edit_medications_dialog_remove_all); for (int i = 0; i < medicationsJsonArrayLength; i++) { JSONObject medicationJsonObject = mPatientMedicationsJsonArray.getJSONObject(i); String name = medicationJsonObject.getString("name"); String manufacturer = medicationJsonObject.getString("manufacturer"); medicationsNamesArrayList.add(name); medicationsManufacturersArrayList.add(manufacturer); medicationsNamesStringArrayList[i + 2] = name; } String medicationsNames = ""; for (int n = 0; n < medicationsNamesArrayList.size(); n++) { medicationsNames += medicationsNamesArrayList.get(n) + ", "; } medicationsNames = medicationsNames.replaceAll(", $", ""); mPatientMedicationsTextView.setText(Html.fromHtml("<u>" + medicationsNames + "</u>")); mPatientMedicationsTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new MaterialDialog.Builder(mContext) .title(getString(R.string.notes_edit_medications_dialog_title)) .items(medicationsNamesStringArrayList) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) { if (i == 0) { String medicationsInteractions = ""; for (int n = 0; n < medicationsNamesArrayList.size(); n++) { medicationsInteractions += medicationsNamesArrayList.get(n) .split(" ")[0] + " "; } medicationsInteractions = medicationsInteractions.trim(); Intent intent = new Intent(mContext, InteractionsCardsActivity.class); intent.putExtra("search", medicationsInteractions); startActivity(intent); } else if (i == 1) { try { mPatientMedicationsJsonArray = new JSONArray("[]"); getMedications(); } catch (Exception e) { Log.e("NotesEditActivity", Log.getStackTraceString(e)); } } else { int position = i - 2; String medicationName = medicationsNamesArrayList.get(position); String medicationManufacturer = medicationsManufacturersArrayList .get(position); SQLiteDatabase sqLiteDatabase = new SlDataSQLiteHelper(mContext) .getReadableDatabase(); String[] queryColumns = { SlDataSQLiteHelper.MEDICATIONS_COLUMN_ID }; Cursor cursor = sqLiteDatabase.query( SlDataSQLiteHelper.TABLE_MEDICATIONS, queryColumns, SlDataSQLiteHelper.MEDICATIONS_COLUMN_NAME + " = " + mTools.sqe(medicationName) + " AND " + SlDataSQLiteHelper.MEDICATIONS_COLUMN_MANUFACTURER + " = " + mTools.sqe(medicationManufacturer), null, null, null, null); if (cursor.moveToFirst()) { long id = cursor.getLong(cursor.getColumnIndexOrThrow( SlDataSQLiteHelper.MEDICATIONS_COLUMN_ID)); Intent intent = new Intent(mContext, MedicationActivity.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mTools.getDefaultSharedPreferencesBoolean( "MEDICATION_MULTIPLE_DOCUMENTS")) intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } intent.putExtra("id", id); startActivity(intent); } cursor.close(); sqLiteDatabase.close(); } } }).itemColorRes(R.color.dark_blue).show(); } }); } } catch (Exception e) { Log.e("NotesEditActivity", Log.getStackTraceString(e)); } }
From source file:hku.fyp14017.blencode.ui.controller.SoundController.java
public void copySound(int position, ArrayList<SoundInfo> soundInfoList, SoundBaseAdapter adapter) { SoundInfo soundInfo = soundInfoList.get(position); try {//ww w .j a v a2s . c o m StorageHandler.getInstance().copySoundFile(soundInfo.getAbsolutePath()); } catch (IOException ioException) { Log.e(TAG, Log.getStackTraceString(ioException)); } SoundController.getInstance().updateSoundAdapter(soundInfo.getTitle(), soundInfo.getSoundFileName(), soundInfoList, adapter); }
From source file:org.alfresco.mobile.android.application.fragments.upload.UploadFormFragment.java
private File createFile(File localParentFolder, String filename, String data) { File outputFile = null;/*from w w w . ja va 2 s .co m*/ Writer writer = null; try { if (!localParentFolder.isDirectory()) { localParentFolder.mkdir(); } outputFile = new File(localParentFolder, filename); writer = new BufferedWriter(new FileWriter(outputFile)); writer.write(data); writer.close(); } catch (IOException e) { Log.w(TAG, Log.getStackTraceString(e)); } return outputFile; }
From source file:it.geosolutions.geocollect.android.core.form.FormEditActivity.java
@Override protected void onDestroy() { super.onDestroy(); if (this.mapViewManager != null) { this.mapViewManager.destroyMapViews(); }//from w w w. j a v a 2 s . c om if (this.spatialiteDatabase != null) { try { this.spatialiteDatabase.close(); Log.v("FORM_EDIT", "Spatialite Database Closed"); } catch (jsqlite.Exception e) { Log.e("FORM_EDIT", Log.getStackTraceString(e)); } } }
From source file:org.alfresco.mobile.android.application.providers.storage.StorageAccessDocumentsProvider.java
@Override public ParcelFileDescriptor openDocument(String documentId, String mode, CancellationSignal signal) throws FileNotFoundException { // Log.d(TAG, "Open Document : " + documentId); try {/*from w w w.j a v a 2s . co m*/ EncodedQueryUri cUri = new EncodedQueryUri(documentId); checkSession(cUri); Node currentNode = retrieveNode(cUri.id); try { // DocumentId can be an old one stored as "recent doc" // This id might have been updated/changed until the last access // That's why We ALWAYS request the latest version // Log.d(TAG, "retrieve latest version"); currentNode = session.getServiceRegistry().getVersionService() .getLatestVersion((org.alfresco.mobile.android.api.model.Document) currentNode); } catch (AlfrescoServiceException e) { // Specific edge case on old version of Alfresco // the first version number can be 0.1 instead of 1.0 // So we try to find this version instead the default 1.0 String id = NodeRefUtils.getCleanIdentifier(cUri.id); if (session instanceof RepositorySession) { id = NodeRefUtils.createNodeRefByIdentifier(id) + ";0.1"; } currentNode = session.getServiceRegistry().getDocumentFolderService().getNodeByIdentifier(id); currentNode = session.getServiceRegistry().getVersionService() .getLatestVersion((org.alfresco.mobile.android.api.model.Document) currentNode); } nodesIndex.put(NodeRefUtils.getVersionIdentifier(cUri.id), currentNode); nodesIndex.put(NodeRefUtils.getVersionIdentifier(currentNode.getIdentifier()), currentNode); // Check Document has Content if (currentNode.isFolder()) { return null; } // It's a document so let's write the local file! // Store the document inside a temporary folder per account File downloadedFile = null; if (getContext() != null && currentNode != null && session != null) { File folder = AlfrescoStorageManager.getInstance(getContext()).getShareFolder(selectedAccount); if (folder != null) { String extension = MimeTypeManager.getExtension(currentNode.getName()); String name = NodeRefUtils.getVersionIdentifier(currentNode.getIdentifier()); if (!TextUtils.isEmpty(extension)) { name = name.concat(".").concat(extension); } downloadedFile = new File(folder, name); } } // Check the mode final int accessMode = ParcelFileDescriptor.parseMode(mode); final boolean isWrite = (mode.indexOf('w') != -1); // Is Document in cache ? if (downloadedFile != null && downloadedFile.exists() && currentNode.getModifiedAt().getTimeInMillis() < downloadedFile.lastModified()) { // Document available locally return createFileDescriptor((org.alfresco.mobile.android.api.model.Document) currentNode, isWrite, downloadedFile, accessMode); } // Not in cache so let's download the content if it has content ! if (((org.alfresco.mobile.android.api.model.Document) currentNode).getContentStreamLength() != 0) { ContentStream contentStream = session.getServiceRegistry().getDocumentFolderService() .getContentStream((org.alfresco.mobile.android.api.model.Document) currentNode); // Check Stream if (contentStream == null || contentStream.getLength() == 0) { return null; } // Copy the content locally. copyFile(contentStream.getInputStream(), contentStream.getLength(), downloadedFile, signal); } else { downloadedFile.createNewFile(); } if (downloadedFile.exists()) { // Document available locally return createFileDescriptor((org.alfresco.mobile.android.api.model.Document) currentNode, isWrite, downloadedFile, accessMode); } else { return null; } } catch (Exception e) { Log.w(TAG, Log.getStackTraceString(e)); throw new FileNotFoundException("Unable to find this document"); } }
From source file:net.olejon.mdapp.DiseasesAndTreatmentsSearchActivity.java
private void search(final String language, final String string, final boolean cache) { mFirstPubMedPosition = 0;//from w w w. ja v a 2 s. c om mFirstWebOfSciencePosition = 0; mFirstMedlinePlusPosition = 0; mFirstWikipediaPosition = 0; mFirstUpToDatePosition = 0; mFirstBmjPosition = 0; mFirstNhiPosition = 0; mFirstSmlPosition = 0; mFirstForskningPosition = 0; mFirstHelsebiblioteketPosition = 0; mFirstTidsskriftetPosition = 0; mFirstOncolexPosition = 0; mFirstBrukerhandbokenPosition = 0; mFirstHelsenorgePosition = 0; try { RequestQueue requestQueue = Volley.newRequestQueue(mContext); String apiUri = getString(R.string.project_website_uri) + "api/1/diseases-and-treatments/" + language + "/?search=" + URLEncoder.encode(string, "utf-8"); if (!cache) requestQueue.getCache().remove(apiUri); JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(apiUri, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { for (int i = 0; i < response.length(); i++) { try { JSONObject jsonObject = response.getJSONObject(i); String type = jsonObject.getString("type"); if (mFirstPubMedPosition == 0 && type.equals("pubmed")) mFirstPubMedPosition = i; if (mFirstWebOfSciencePosition == 0 && type.equals("webofscience")) mFirstWebOfSciencePosition = i; if (mFirstMedlinePlusPosition == 0 && type.equals("medlineplus")) mFirstMedlinePlusPosition = i; if (mFirstWikipediaPosition == 0 && type.equals("wikipedia")) mFirstWikipediaPosition = i; if (mFirstUpToDatePosition == 0 && type.equals("uptodate")) mFirstUpToDatePosition = i; if (mFirstBmjPosition == 0 && type.equals("bmj")) mFirstBmjPosition = i; if (mFirstNhiPosition == 0 && type.equals("nhi")) mFirstNhiPosition = i; if (mFirstSmlPosition == 0 && type.equals("sml")) mFirstSmlPosition = i; if (mFirstForskningPosition == 0 && type.equals("forskning")) mFirstForskningPosition = i; if (mFirstHelsebiblioteketPosition == 0 && type.equals("helsebiblioteket")) mFirstHelsebiblioteketPosition = i; if (mFirstTidsskriftetPosition == 0 && type.equals("tidsskriftet")) mFirstTidsskriftetPosition = i; if (mFirstOncolexPosition == 0 && type.equals("oncolex")) mFirstOncolexPosition = i; if (mFirstBrukerhandbokenPosition == 0 && type.equals("brukerhandboken")) mFirstBrukerhandbokenPosition = i; if (mFirstHelsenorgePosition == 0 && type.equals("helsenorge")) mFirstHelsenorgePosition = i; } catch (Exception e) { Log.e("DiseasesAndTreatments", Log.getStackTraceString(e)); } } mProgressBar.setVisibility(View.GONE); mSwipeRefreshLayout.setRefreshing(false); if (mTools.isTablet()) mRecyclerView.setLayoutManager( new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); mRecyclerView.setAdapter(new DiseasesAndTreatmentsSearchAdapter(mContext, response, string)); ContentValues contentValues = new ContentValues(); contentValues.put(DiseasesAndTreatmentsSQLiteHelper.COLUMN_STRING, string); SQLiteDatabase sqLiteDatabase = new DiseasesAndTreatmentsSQLiteHelper(mContext) .getWritableDatabase(); sqLiteDatabase.delete(DiseasesAndTreatmentsSQLiteHelper.TABLE, DiseasesAndTreatmentsSQLiteHelper.COLUMN_STRING + " = " + mTools.sqe(string) + " COLLATE NOCASE", null); sqLiteDatabase.insert(DiseasesAndTreatmentsSQLiteHelper.TABLE, null, contentValues); sqLiteDatabase.close(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { mProgressBar.setVisibility(View.GONE); mSwipeRefreshLayout.setRefreshing(false); mTools.showToast(getString(R.string.diseases_and_treatments_search_could_not_search), 1); Log.e("DiseasesAndTreatments", error.toString()); finish(); } }); jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(jsonArrayRequest); } catch (Exception e) { Log.e("DiseasesAndTreatments", Log.getStackTraceString(e)); } }
From source file:net.olejon.mdapp.CalculatorsActivity.java
private void calculateCorrectedQtTime() { EditText qtIntervalEditText = (EditText) findViewById(R.id.calculators_corrected_qt_time_qt_interval); EditText rrIntervalEditText = (EditText) findViewById(R.id.calculators_corrected_qt_time_rr_interval); String qtIntervalEditTextValue = qtIntervalEditText.getText().toString(); String rrIntervalEditTextValue = rrIntervalEditText.getText().toString(); if (qtIntervalEditTextValue.equals("") || rrIntervalEditTextValue.equals("")) { mTools.showToast(getString(R.string.calculators_corrected_qt_time_invalid_values), 1); } else {// w ww . j a va 2 s . c o m try { double qtInterval = Double.parseDouble(qtIntervalEditTextValue) * 0.001; double rrInterval = Double.parseDouble(rrIntervalEditTextValue) * 0.001; int result = (int) Math.round(qtInterval / Math.sqrt(rrInterval) * 1000); new MaterialDialog.Builder(mContext) .title(getString(R.string.calculators_corrected_qt_time_dialog_title)) .content( Html.fromHtml(getString(R.string.calculators_corrected_qt_time_dialog_message_first) + "<br><b>" + result + " ms</b><br><br><small><i>" + getString(R.string.calculators_corrected_qt_time_dialog_message_second) + "</i></small>")) .positiveText(getString(R.string.calculators_corrected_qt_time_dialog_positive_button)) .neutralText(getString(R.string.calculators_corrected_qt_time_dialog_neutral_button)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onNeutral(MaterialDialog dialog) { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.calculators_corrected_qt_time_dialog_title)); intent.putExtra("uri", "http://tidsskriftet.no/article/218317"); startActivity(intent); } }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue) .neutralColorRes(R.color.dark_blue).show(); } catch (Exception e) { mTools.showToast(getString(R.string.calculators_corrected_qt_time_invalid_values), 1); Log.e("CalculatorsActivity", Log.getStackTraceString(e)); } } }