List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:com.kth.common.utils.etc.LogUtil.java
/** * INFO ?.//from ww w . j a v a 2 s . c om * * @param clazz ?? Class. * @param msg . * @param tr Throwable. */ public static void i(final Class<?> clazz, final String msg, final Throwable tr) { if (LogUtil.isInfoEnabled()) { Log.println(Log.INFO, TAG, LogUtil.getClassLineNumber(clazz) + " - " + msg + '\n' + Log.getStackTraceString(tr)); // ?? ? ?. if (LogUtil.isFileLogEnabled()) { write(Log.INFO, LogUtil.getClassLineNumber(clazz), msg, tr); } } }
From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionDetailActivity.java
@Override protected void onDestroy() { super.onDestroy(); if (this.mapViewManager != null) { this.mapViewManager.destroyMapViews(); }/*from ww w. j ava2 s. c o m*/ if (this.spatialiteDatabase != null) { try { this.spatialiteDatabase.close(); Log.v("MISSION_DETAIL", "Spatialite Database Closed"); } catch (jsqlite.Exception e) { Log.e("MISSION_DETAIL", Log.getStackTraceString(e)); } } }
From source file:com.dm.wallpaper.board.fragments.dialogs.InAppBillingFragment.java
private void loadInAppProducts() { mLoadInAppProducts = new AsyncTask<Void, Void, Boolean>() { InAppBilling[] inAppBillings;/*from www . j a va2s. c o m*/ boolean isBillingNotReady = false; @Override protected void onPreExecute() { super.onPreExecute(); mProgress.setVisibility(View.VISIBLE); inAppBillings = new InAppBilling[mProductsId.length]; } @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); if (mBillingProcessor == null) { isBillingNotReady = true; return false; } for (int i = 0; i < mProductsId.length; i++) { SkuDetails product = mBillingProcessor.getPurchaseListingDetails(mProductsId[i]); if (product != null) { InAppBilling inAppBilling; String title = product.title.substring(0, product.title.lastIndexOf("(")); inAppBilling = new InAppBilling(product.priceText, mProductsId[i], title); inAppBillings[i] = inAppBilling; } else { if (i == mProductsId.length - 1) return false; } } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); mProgress.setVisibility(View.GONE); if (aBoolean) { mAdapter = new InAppBillingAdapter(getActivity(), inAppBillings); mListView.setAdapter(mAdapter); } else { dismiss(); if (!isBillingNotReady) Toast.makeText(getActivity(), R.string.billing_load_product_failed, Toast.LENGTH_LONG) .show(); } mLoadInAppProducts = null; } }.execute(); }
From source file:org.proninyaroslav.libretorrent.core.IPFilterParser.java
public static boolean parseP2PFilterFile(String path, ip_filter filter) { if (path == null || filter == null) { return false; }/* w ww.j av a2 s . com*/ File file = new File(path); if (!file.exists()) { return false; } LineIterator it = null; try { it = FileUtils.lineIterator(file, "UTF-8"); } catch (IOException e) { Log.e(TAG, Log.getStackTraceString(e)); } if (it == null) { return false; } long lineNum = 0; long badLineNum = 0; try { while (it.hasNext()) { ++lineNum; String line = it.nextLine(); line = line.trim(); if (line.isEmpty()) { continue; } /* Ignoring commented lines */ if (line.startsWith("#") || line.startsWith("//")) { continue; } /* Line should be split by ':' */ String[] parts = line.split(":"); if (parts.length < 2) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); ++badLineNum; continue; } /* IP Range should be split by a dash */ String[] ips = parts[1].split("-"); if (ips.length != 2) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); Log.w(TAG, "Line was " + line); ++badLineNum; continue; } String startIp = cleanupIPAddress(ips[0]); if (startIp == null || startIp.isEmpty()) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); Log.w(TAG, "Start IP of the range is malformated: " + ips[0]); ++badLineNum; continue; } error_code error = new error_code(); address startAddr = address.from_string(startIp, error); if (error.value() > 0) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); Log.w(TAG, "Start IP of the range is malformated:" + ips[0]); ++badLineNum; continue; } String endIp = cleanupIPAddress(ips[1]); if (endIp == null || endIp.isEmpty()) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); Log.w(TAG, "End IP of the range is malformated: " + ips[1]); ++badLineNum; continue; } address endAddr = address.from_string(endIp, error); if (error.value() > 0) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); Log.w(TAG, "End IP of the range is malformated:" + ips[1]); ++badLineNum; continue; } if (startAddr.is_v4() != endAddr.is_v4()) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); Log.w(TAG, "One IP is IPv4 and the other is IPv6!"); ++badLineNum; continue; } try { filter.add_rule(startAddr, endAddr, ip_filter.access_flags.blocked.swigValue()); } catch (Exception e) { Log.w(TAG, "parseP2PFilterFile: line " + lineNum + " is malformed."); Log.w(TAG, "Line was " + line); ++badLineNum; } } } finally { it.close(); } return badLineNum < lineNum; }
From source file:com.dm.material.dashboard.candybar.activities.CandyBarMuzeiActivity.java
private void setDividerColor(NumberPicker picker) { java.lang.reflect.Field[] pickerFields = NumberPicker.class.getDeclaredFields(); for (java.lang.reflect.Field pf : pickerFields) { if (pf.getName().equals("mSelectionDivider")) { pf.setAccessible(true);// w ww . j av a 2s .c o m try { pf.set(picker, ContextCompat.getDrawable(this, Preferences.getPreferences(this).isDarkTheme() ? R.drawable.numberpicker_divider_dark : R.drawable.numberpicker_divider)); } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); } break; } } }
From source file:org.catrobat.catroid.ui.fragment.SoundFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); listView = getListView();/*from w ww . j a v a 2 s .co m*/ registerForContextMenu(listView); if (savedInstanceState != null) { selectedSoundInfo = (SoundInfo) savedInstanceState .getSerializable(SoundController.BUNDLE_ARGUMENTS_SELECTED_SOUND); } try { soundInfoList = ProjectManager.getInstance().getCurrentSprite().getSoundList(); } catch (NullPointerException nullPointerException) { Log.e(TAG, Log.getStackTraceString(nullPointerException)); soundInfoList = new ArrayList<SoundInfo>(); } adapter = new SoundAdapter(getActivity(), R.layout.fragment_sound_soundlist_item, R.id.fragment_sound_item_title_text_view, soundInfoList, false); adapter.setOnSoundEditListener(this); setListAdapter(adapter); ((SoundAdapter) adapter).setSoundFragment(this); Utils.loadProjectIfNeeded(getActivity()); setHandleAddbutton(); // set adapter and soundInfoList for ev. unpacking BackPackListManager.getInstance().setCurrentSoundInfoList(soundInfoList); BackPackListManager.getInstance().setCurrentSoundAdapter(adapter); }
From source file:com.google.wireless.speed.speedometer.Checkin.java
public List<MeasurementTask> checkin() throws IOException { Log.i(SpeedometerApp.TAG, "Checkin.checkin() called"); boolean checkinSuccess = false; try {//from w w w .j a va 2 s .co m JSONObject status = new JSONObject(); DeviceInfo info = phoneUtils.getDeviceInfo(); // TODO(Wenjie): There is duplicated info here, such as device ID. status.put("id", info.deviceId); status.put("manufacturer", info.manufacturer); status.put("model", info.model); status.put("os", info.os); status.put("properties", MeasurementJsonConvertor.encodeToJson(phoneUtils.getDeviceProperty())); Log.d(SpeedometerApp.TAG, status.toString()); sendStringMsg("Checking in"); String result = speedometerServiceRequest("checkin", status.toString()); Log.d(SpeedometerApp.TAG, "Checkin result: " + result); // Parse the result Vector<MeasurementTask> schedule = new Vector<MeasurementTask>(); JSONArray jsonArray = new JSONArray(result); sendStringMsg("Checkin got " + jsonArray.length() + " tasks."); for (int i = 0; i < jsonArray.length(); i++) { Log.d(SpeedometerApp.TAG, "Parsing index " + i); JSONObject json = jsonArray.optJSONObject(i); Log.d(SpeedometerApp.TAG, "Value is " + json); if (json != null) { try { MeasurementTask task = MeasurementJsonConvertor.makeMeasurementTaskFromJson(json, this.context); Log.i(SpeedometerApp.TAG, MeasurementJsonConvertor.toJsonString(task.measurementDesc)); schedule.add(task); } catch (IllegalArgumentException e) { Log.w(SpeedometerApp.TAG, "Could not create task from JSON: " + e); // Just skip it, and try the next one } } } this.lastCheckin = new Date(); Log.i(SpeedometerApp.TAG, "Checkin complete, got " + schedule.size() + " new tasks"); checkinSuccess = true; return schedule; } catch (JSONException e) { Log.e(SpeedometerApp.TAG, "Got exception during checkin: " + Log.getStackTraceString(e)); throw new IOException("There is exception during checkin()"); } catch (IOException e) { Log.e(SpeedometerApp.TAG, "Got exception during checkin: " + Log.getStackTraceString(e)); throw e; } finally { if (!checkinSuccess) { // Failure probably due to authToken expiration. Will authenticate upon next checkin. this.accountSelector.setAuthImmediately(true); this.authCookie = null; } } }
From source file:hku.fyp14017.blencode.ui.dialogs.NewProjectDialog.java
protected void handleOkButtonClick() { String projectName = newProjectEditText.getText().toString().trim(); boolean shouldBeEmpty = emptyProjectCheckBox.isChecked(); if (projectName.isEmpty()) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.error_no_name_entered); return;/*from w w w .ja v a 2s . co m*/ } if (Utils.checkIfProjectExistsOrIsDownloadingIgnoreCase(projectName)) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.error_project_exists); return; } try { ProjectManager.getInstance().initializeNewProject(projectName, getActivity(), shouldBeEmpty); } catch (IllegalArgumentException illegalArgumentException) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.error_project_exists); return; } catch (IOException ioException) { Utils.showErrorDialog(getActivity(), hku.fyp14017.blencode.R.string.error_new_project); Log.e(TAG, Log.getStackTraceString(ioException)); dismiss(); return; } sharedPreferences.edit().putBoolean(SHARED_PREFERENCES_EMPTY_PROJECT, shouldBeEmpty).commit(); Utils.saveToPreferences(getActivity(), Constants.PREF_PROJECTNAME_KEY, projectName); Intent intent = new Intent(getActivity(), ProjectActivity.class); intent.putExtra(Constants.PROJECTNAME_TO_LOAD, projectName); if (isOpenendFromProjectList()) { intent.putExtra(Constants.PROJECT_OPENED_FROM_PROJECTS_LIST, true); } getActivity().startActivity(intent); dismiss(); }
From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java
@Override public void onCreate(Bundle savedInstanceState) { AnalyticsHelper.reportScreen(this, AnalyticsManager.SCREEN_SAMSUNG_SNOTE_EDITOR); super.onCreate(savedInstanceState); setContentView(R.layout.snote_editor); context = this; // TOOLBAR//w w w . j a v a2 s . c o m Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } // Retrieve information String action = getIntent().getAction(); if (Intent.ACTION_VIEW.equals(action)) { if (getIntent().getData() != null) { String filePath = BaseActionUtils.getPath(this, getIntent().getData()); file = new File(filePath); } else { AlfrescoNotificationManager.getInstance(this).showLongToast(getString(R.string.editor_error_open)); finish(); return; } } // Init Spen boolean isSpenFeatureEnabled = false; Spen spenPackage = new Spen(); try { spenPackage.initialize(this); isSpenFeatureEnabled = spenPackage.isFeatureEnabled(Spen.DEVICE_PEN); } catch (SsdkUnsupportedException e) { if (SNoteUtils.processUnsupportedException(this, e)) { return; } } catch (Exception e1) { Log.e(TAG, Log.getStackTraceString(e1)); finish(); } FrameLayout spenViewContainer = (FrameLayout) findViewById(R.id.spenViewContainer); RelativeLayout spenViewLayout = (RelativeLayout) findViewById(R.id.spenViewLayout); // PEN SETTINGS spenSettingView = new SpenSettingPenLayout(context, "", spenViewLayout); if (spenSettingView == null) { finish(); } spenViewContainer.addView(spenSettingView); // ERASER SETTINGS eraserSettingView = new SpenSettingEraserLayout(context, "", spenViewLayout); if (eraserSettingView == null) { finish(); } spenViewContainer.addView(eraserSettingView); // TEXT SETTINGS textSettingView = new SpenSettingTextLayout(context, "", new HashMap<String, String>(), spenViewLayout); if (textSettingView == null) { finish(); } spenViewContainer.addView(textSettingView); // SELECTION SETTINGS selectionSettingView = new SpenSettingSelectionLayout(context, "", spenViewLayout); if (textSettingView == null) { finish(); } spenViewContainer.addView(selectionSettingView); // SURFACE VIEW spenSurfaceView = new SpenSurfaceView(context); if (spenSurfaceView == null) { finish(); } spenViewLayout.addView(spenSurfaceView); spenSettingView.setCanvasView(spenSurfaceView); eraserSettingView.setCanvasView(spenSurfaceView); textSettingView.setCanvasView(spenSurfaceView); selectionSettingView.setCanvasView(spenSurfaceView); // NOTE DOCUMENT Display display = getWindowManager().getDefaultDisplay(); Rect mScreenRect = new Rect(); display.getRectSize(mScreenRect); try { if (file != null && file.length() > 0) { spenNoteDoc = new SpenNoteDoc(context, file.getAbsolutePath(), mScreenRect.width(), SpenNoteDoc.MODE_WRITABLE); if (spenNoteDoc.getPageCount() == 0) { spenPageDoc = spenNoteDoc.appendPage(); } else { spenPageDoc = spenNoteDoc.getPage(spenNoteDoc.getLastEditedPageIndex()); } } else { spenNoteDoc = new SpenNoteDoc(context, SpenNoteDoc.ORIENTATION_LANDSCAPE, (mScreenRect.width() > mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height(), (mScreenRect.width() < mScreenRect.height()) ? mScreenRect.width() : mScreenRect.height()); spenPageDoc = spenNoteDoc.appendPage(); spenPageDoc.setBackgroundColor(getResources().getColor(android.R.color.white)); spenPageDoc.clearHistory(); } } catch (Exception e) { finish(); } // Display Document spenSurfaceView.setPageDoc(spenPageDoc, true); spenSurfaceView.setBlankColor(getResources().getColor(R.color.grey_light)); if (!isSpenFeatureEnabled) { mToolType = SpenSurfaceView.TOOL_FINGER; spenSurfaceView.setToolTypeAction(mToolType, SpenSurfaceView.ACTION_STROKE); // Touch listener for swipe if on Finger mode gdt = new GestureDetector(context, new GestureListener()); spenSurfaceView.setOnTouchListener(touchListener); } // Init Pages mTxtView = (TextView) findViewById(R.id.spen_page); mTxtView.setText(String.format(getString(R.string.editor_paging), String.valueOf((spenNoteDoc.getPageIndexById(spenPageDoc.getId()) + 1)), spenNoteDoc.getPageCount())); // INIT Setting & Listeners initSettingInfo(); spenSurfaceView.setTouchListener(penTouchListener); spenSurfaceView.setControlListener(controlListener); spenSurfaceView.setFlickListener(mFlickListener); }
From source file:com.dm.material.dashboard.candybar.fragments.dialog.IntentChooserFragment.java
private void loadIntentChooser() { mLoadIntentChooser = new AsyncTask<Void, Void, Boolean>() { List<IntentChooser> apps; @Override/*from ww w. j a v a 2 s. c om*/ protected void onPreExecute() { super.onPreExecute(); apps = new ArrayList<>(); } @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getActivity().getResources().getString(R.string.dev_email), null)); List<ResolveInfo> resolveInfos = getActivity().getPackageManager() .queryIntentActivities(intent, 0); try { Collections.sort(resolveInfos, new ResolveInfo.DisplayNameComparator(getActivity().getPackageManager())); } catch (Exception ignored) { } for (ResolveInfo resolveInfo : resolveInfos) { switch (resolveInfo.activityInfo.packageName) { case "com.google.android.gm": apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_RECOMMENDED)); break; case "com.google.android.apps.inbox": apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_NOT_SUPPORTED)); break; case "com.android.fallback": case "com.paypal.android.p2pmobile": case "com.lonelycatgames.Xplore": break; default: apps.add(new IntentChooser(resolveInfo, IntentChooser.TYPE_SUPPORTED)); break; } } return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); if (aBoolean && apps != null) { IntentAdapter adapter = new IntentAdapter(getActivity(), apps, mRequest); mIntentList.setAdapter(adapter); if (apps.size() == 0) { mNoApp.setVisibility(View.VISIBLE); setCancelable(true); } if (apps.size() == 1) { if (apps.get(0).getApp().activityInfo.packageName.equals("com.google.android.apps.inbox")) setCancelable(true); } } else { dismiss(); Toast.makeText(getActivity(), R.string.intent_email_failed, Toast.LENGTH_LONG).show(); } mLoadIntentChooser = null; } }.execute(); }