List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:eu.operando.proxy.filters.domain.DomainFiltersActivity.java
protected void importExternalFilters(final String importUrl) { //String timestap = SimpleDateFormat.getDateTimeInstance().format(new Date().getTime()); final File tmp = new File(getFilesDir(), "domainfilters_" + System.currentTimeMillis()); try {// w ww. j a v a 2 s . c o m new DownloadTask(DomainFiltersActivity.this, new URL(importUrl), tmp, new DownloadTask.Listener() { @Override public void onCompleted() { Toast.makeText(DomainFiltersActivity.this, R.string.msg_downloaded, Toast.LENGTH_LONG).show(); new AsyncTask<Void, Void, Integer>() { ProgressDialog dialog; @Override protected void onPreExecute() { dialog = ProgressDialog.show(DomainFiltersActivity.this, null, "Parsing downloaded file..."); dialog.setCancelable(false); } @Override protected Integer doInBackground(Void... params) { Integer count = 0; BufferedReader br = null; try { br = new BufferedReader(new FileReader(tmp)); String line; while ((line = br.readLine()) != null) { int hash = line.indexOf('#'); if (hash >= 0) line = line.substring(0, hash); line = line.trim(); if (line.length() > 0) { String[] words = line.split("\\s+"); if (words.length == 2) { String blockedDomain = words[1].toLowerCase(); if (blockedDomain.equals("local") || StringUtils.containsAny( blockedDomain, "localhost", "127.0.0.1", "broadcasthost")) continue; DomainFilter domainFilter = new DomainFilter(); domainFilter.setContent(blockedDomain); domainFilter.setSource(importUrl); domainFilter.setIsWildcard(false); db.createDomainFilter(domainFilter); count++; } else Log.i(TAG, "Invalid hosts file line: " + line); } } Log.i(TAG, count + " entries read"); } catch (IOException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } finally { if (br != null) try { br.close(); } catch (IOException exex) { Log.e(TAG, exex.toString() + "\n" + Log.getStackTraceString(exex)); } } return count; } @Override protected void onPostExecute(Integer count) { dialog.dismiss(); if (count > 0) { updateFiltersList(); externalDomainFiltersAdapter.notifyDataSetChanged(); } } }.execute(); } @Override public void onCancelled() { if (tmp.exists()) tmp.delete(); } @Override public void onException(Throwable ex) { if (tmp.exists()) tmp.delete(); ex.printStackTrace(); Toast.makeText(DomainFiltersActivity.this, ex.getMessage(), Toast.LENGTH_LONG).show(); } }).execute(); } catch (MalformedURLException ex) { ex.printStackTrace(); Toast.makeText(DomainFiltersActivity.this, ex.toString(), Toast.LENGTH_LONG).show(); } }
From source file:org.alfresco.mobile.android.application.activity.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); try {/*from w ww . j a va2 s . c o m*/ // Shortcut to display favorites panel. if (PrivateIntent.ACTION_SYNCHRO_DISPLAY.equals(intent.getAction())) { if (!isVisible(SyncFragment.TAG)) { SyncFragment.with(this).display(); } return; } // Intent for Scan result // Only associated with DocumentFolderBrowserFragment if (PrivateIntent.ACTION_SCAN_RESULT.equals(intent.getAction())) { if (getFragment(DocumentFolderBrowserFragment.TAG) != null && intent.getExtras() != null) { ArrayList<String> tempList = intent.getStringArrayListExtra(PrivateIntent.EXTRA_FILE_PATH); if (tempList == null) { return; } List<File> files = new ArrayList<File>(tempList.size()); int nCnt; for (nCnt = tempList.size(); nCnt > 0; nCnt--) { files.add(new File(tempList.get(nCnt - 1))); } ((DocumentFolderBrowserFragment) getFragment(DocumentFolderBrowserFragment.TAG)) .createFiles(files); } return; } // Is it from an alfresco shortcut ? openShortcut(intent); } catch (Exception e) { Log.w(TAG, Log.getStackTraceString(e)); } }
From source file:org.catrobat.catroid.ui.controller.LookController.java
public void loadPocketPaintImageIntoCatroid(Intent intent, Activity activity, LookData selectedLookData) { Bundle bundle = intent.getExtras();//from w ww . jav a2 s.co m String pathOfPocketPaintImage = bundle.getString(Constants.EXTRA_PICTURE_PATH_POCKET_PAINT); int[] imageDimensions = ImageEditing.getImageDimensions(pathOfPocketPaintImage); if (imageDimensions[0] < 0 || imageDimensions[1] < 0) { Utils.showErrorDialog(activity, R.string.error_load_image); return; } String actualChecksum = Utils.md5Checksum(new File(pathOfPocketPaintImage)); // If look changed --> saving new image with new checksum and changing lookData if (!selectedLookData.getChecksum().equalsIgnoreCase(actualChecksum)) { String oldFileName = selectedLookData.getLookFileName(); String newFileName = oldFileName.substring(oldFileName.indexOf('_') + 1); //HACK for https://github.com/Catrobat/Catroid/issues/81 if (!newFileName.endsWith(".png")) { newFileName = newFileName + ".png"; } String projectName = ProjectManager.getInstance().getCurrentProject().getName(); try { File newLookFile = StorageHandler.getInstance().copyImage(projectName, pathOfPocketPaintImage, newFileName); StorageHandler.getInstance().deleteFile(selectedLookData.getAbsolutePath()); //reduce usage in container or delete it selectedLookData.setLookFilename(newLookFile.getName()); selectedLookData.resetThumbnailBitmap(); } catch (IOException ioException) { Log.e(TAG, Log.getStackTraceString(ioException)); } } }
From source file:eu.operando.operandoapp.filters.domain.DomainFiltersActivity.java
protected void importExternalFilters(final String importUrl) { final File tmp = new File(getFilesDir(), "domainfilters_" + System.currentTimeMillis()); try {//w w w .j a va 2 s . co m new DownloadTask(DomainFiltersActivity.this, new URL(importUrl), tmp, new DownloadTask.Listener() { @Override public void onCompleted() { //Toast.makeText(DomainFiltersActivity.this, R.string.msg_downloaded, Toast.LENGTH_LONG).show(); new AsyncTask<Void, Void, Integer>() { ProgressDialog dialog; @Override protected void onPreExecute() { dialog = ProgressDialog.show(DomainFiltersActivity.this, null, "Parsing downloaded file..."); dialog.setCancelable(false); } @Override protected Integer doInBackground(Void... params) { Integer count = 0; BufferedReader br = null; try { br = new BufferedReader(new FileReader(tmp)); String line; while ((line = br.readLine()) != null) { int hash = line.indexOf('#'); if (hash >= 0) line = line.substring(0, hash); line = line.trim(); try { String blockedDomain = line; if (blockedDomain.equals("local") || StringUtils.containsAny(blockedDomain, "localhost", "127.0.0.1", "broadcasthost")) continue; DomainFilter domainFilter = new DomainFilter(); domainFilter.setContent(blockedDomain); domainFilter.setSource(importUrl); domainFilter.setIsWildcard(false); db.createDomainFilter(domainFilter); count++; } catch (Exception e) { Log.i(TAG, "Invalid hosts file line: " + line); } } Log.i(TAG, count + " entries read"); } catch (IOException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } finally { if (br != null) try { br.close(); } catch (IOException exex) { Log.e(TAG, exex.toString() + "\n" + Log.getStackTraceString(exex)); } } return count; } @Override protected void onPostExecute(Integer count) { dialog.dismiss(); if (count > 0) { updateFiltersList(); externalDomainFiltersAdapter.notifyDataSetChanged(); } } }.execute(); } @Override public void onCancelled() { if (tmp.exists()) tmp.delete(); } @Override public void onException(Throwable ex) { if (tmp.exists()) tmp.delete(); ex.printStackTrace(); Toast.makeText(DomainFiltersActivity.this, ex.getMessage(), Toast.LENGTH_LONG).show(); } }).execute(); } catch (MalformedURLException ex) { ex.printStackTrace(); Toast.makeText(DomainFiltersActivity.this, ex.toString(), Toast.LENGTH_LONG).show(); } }
From source file:net.olejon.mdapp.PoisoningsCardsActivity.java
private void search(final String string, boolean cache) { try {/*from w w w. ja va2 s. c om*/ RequestQueue requestQueue = Volley.newRequestQueue(mContext); String apiUri = getString(R.string.project_website_uri) + "api/1/poisonings/?search=" + URLEncoder.encode(string.toLowerCase(), "utf-8"); if (!cache) requestQueue.getCache().remove(apiUri); JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(apiUri, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { mProgressBar.setVisibility(View.GONE); mSwipeRefreshLayout.setRefreshing(false); if (response.length() == 0) { mSwipeRefreshLayout.setVisibility(View.GONE); mNoPoisoningsLayout.setVisibility(View.VISIBLE); } else { if (mTools.isTablet()) { int spanCount = (response.length() == 1) ? 1 : 2; mRecyclerView.setLayoutManager( new StaggeredGridLayoutManager(spanCount, StaggeredGridLayoutManager.VERTICAL)); } mRecyclerView.setAdapter(new PoisoningsCardsAdapter(mContext, response)); ContentValues contentValues = new ContentValues(); contentValues.put(PoisoningsSQLiteHelper.COLUMN_STRING, string); SQLiteDatabase sqLiteDatabase = new PoisoningsSQLiteHelper(mContext).getWritableDatabase(); sqLiteDatabase.delete(PoisoningsSQLiteHelper.TABLE, PoisoningsSQLiteHelper.COLUMN_STRING + " = " + mTools.sqe(string) + " COLLATE NOCASE", null); sqLiteDatabase.insert(PoisoningsSQLiteHelper.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.poisonings_cards_something_went_wrong), 1); finish(); Log.e("PoisoningsCardsActivity", error.toString()); } }); jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(jsonArrayRequest); } catch (Exception e) { Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e)); } }
From source file:io.teak.sdk.DeviceConfiguration.java
private void displayGCMDebugMessage() { if (Teak.isDebug) { final DeviceConfiguration _this = this; Session.whenUserIdIsReadyRun(new Session.SessionRunnable() { @Override//www .j av a2 s .c o m public void run(Session session) { try { String urlString = "https://app.teak.io/apps/" + session.appConfiguration.appId + "/test_accounts/new" + "?api_key=" + URLEncoder.encode(session.userId(), "UTF-8") + "&gcm_push_key=" + URLEncoder.encode(_this.gcmId, "UTF-8") + "&device_manufacturer=" + URLEncoder.encode(_this.deviceManufacturer, "UTF-8") + "&device_model=" + URLEncoder.encode(_this.deviceModel, "UTF-8") + "&device_fallback=" + URLEncoder.encode(_this.deviceFallback, "UTF-8") + "&bundle_id=" + URLEncoder.encode(session.appConfiguration.bundleId, "UTF-8") + "&device_id=" + URLEncoder.encode(_this.deviceId, "UTF-8"); Log.d(LOG_TAG, "If you want to debug or test push notifications on this device please click the link below, or copy/paste into your browser:"); Log.d(LOG_TAG, " " + urlString); } catch (Exception e) { Log.e(LOG_TAG, Log.getStackTraceString(e)); } } }); } }
From source file:com.packetsender.android.PacketListenerService.java
public void onDestroy() { try {/*from w w w . j ava 2s.c o m*/ Log.w("service", DataStorage.FILE_LINE("Closing connections")); tcpserver.close(); udpserver.close(); } catch (IOException e) { Log.w("service", DataStorage.FILE_LINE("IOException error: " + Log.getStackTraceString(e))); } catch (NullPointerException e) { Log.w("service", DataStorage.FILE_LINE("NullPointerException error: " + Log.getStackTraceString(e))); } stopNotification(); }
From source file:com.inrista.loggliest.Loggly.java
/** * Log a verbose message and an exception. * @param key Loggly json field/* w ww. j a va 2 s .c o m*/ * @param msg The log message * @param tr The exception to log */ public static void v(String key, String msg, Throwable tr) { v(key, msg + '\n' + Log.getStackTraceString(tr)); }
From source file:hku.fyp14017.blencode.ui.controller.LookController.java
public void loadPocketPaintImageIntoCatroid(Intent intent, Activity activity, LookData selectedLookData) { Bundle bundle = intent.getExtras();/*w w w . j av a2s.c o m*/ String pathOfPocketPaintImage = bundle.getString(Constants.EXTRA_PICTURE_PATH_POCKET_PAINT); int[] imageDimensions = ImageEditing.getImageDimensions(pathOfPocketPaintImage); if (imageDimensions[0] < 0 || imageDimensions[1] < 0) { Utils.showErrorDialog(activity, hku.fyp14017.blencode.R.string.error_load_image); return; } String actualChecksum = Utils.md5Checksum(new File(pathOfPocketPaintImage)); // If look changed --> saving new image with new checksum and changing lookData if (!selectedLookData.getChecksum().equalsIgnoreCase(actualChecksum)) { String oldFileName = selectedLookData.getLookFileName(); String newFileName = oldFileName.substring(oldFileName.indexOf('_') + 1); //HACK for https://github.com/Catrobat/Catroid/issues/81 if (!newFileName.endsWith(".png")) { newFileName = newFileName + ".png"; } String projectName = ProjectManager.getInstance().getCurrentProject().getName(); try { File newLookFile = StorageHandler.getInstance().copyImage(projectName, pathOfPocketPaintImage, newFileName); StorageHandler.getInstance().deleteFile(selectedLookData.getAbsolutePath()); //reduce usage in container or delete it selectedLookData.setLookFilename(newLookFile.getName()); selectedLookData.resetThumbnailBitmap(); } catch (IOException ioException) { Log.e(TAG, Log.getStackTraceString(ioException)); } } }
From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
private boolean handleOkButton() { EditText editText = (EditText) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_new_object_name_edit_text); String newSpriteName;/*from w w w. j a va2s. c om*/ if (editText.length() == 0) { newSpriteName = editText.getHint().toString(); } else { newSpriteName = editText.getText().toString().trim(); } if (newSpriteName.contains(".")) { int fileExtensionPosition = newSpriteName.indexOf('.'); newSpriteName = newSpriteName.substring(0, fileExtensionPosition); } ProjectManager projectManager = ProjectManager.getInstance(); if (newSpriteName.equalsIgnoreCase("")) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.spritename_invalid); return false; } if (projectManager.spriteExists(newSpriteName)) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.spritename_already_exists); return false; } Sprite sprite = new Sprite(newSpriteName); projectManager.addSprite(sprite); LookData lookData; try { File newLookFile = StorageHandler.getInstance().copyImage(projectManager.getCurrentProject().getName(), lookUri.getPath(), null); String imageFileName = newLookFile.getName(); Utils.rewriteImageFileForStage(getActivity(), newLookFile); lookData = new LookData(); lookData.setLookFilename(imageFileName); lookData.setLookName(newSpriteName); } catch (IOException ioException) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.error_load_image); Log.e(TAG, Log.getStackTraceString(ioException)); return false; } catch (NullPointerException e) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.error_load_image); Log.e(TAG, "somebody might have selected an image and deleted it before it was added"); Log.e(TAG, Log.getStackTraceString(e)); return false; } sprite.getLookDataList().add(lookData); if (requestedAction == ActionAfterFinished.ACTION_UPDATE_SPINNER && spinnerAdapter != null) { Intent broadcastIntent; broadcastIntent = new Intent(ScriptActivity.ACTION_BRICK_LIST_CHANGED); getActivity().sendBroadcast(broadcastIntent); spinnerAdapter.refreshSpinnerAfterNewSprite(getActivity(), newSpriteName); } else { Intent broadcastIntent; broadcastIntent = new Intent(ScriptActivity.ACTION_SPRITES_LIST_CHANGED); getActivity().sendBroadcast(broadcastIntent); } if (requestedAction == ActionAfterFinished.ACTION_FORWARD_TO_NEW_OBJECT) { projectManager.setCurrentSprite(sprite); Intent intent = new Intent(getActivity(), ProgramMenuActivity.class); intent.putExtra(ProgramMenuActivity.FORWARD_TO_SCRIPT_ACTIVITY, ScriptActivity.FRAGMENT_SCRIPTS); startActivity(intent); } dismiss(); return true; }