List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:net.olejon.mdapp.MyTools.java
public String getDevice() { String device = ""; try {//from w w w.jav a 2 s .c o m device = (Build.MANUFACTURER == null || Build.MODEL == null || Build.VERSION.SDK_INT < 1) ? "" : URLEncoder.encode(Build.MANUFACTURER + " " + Build.MODEL + " " + Build.VERSION.SDK_INT, "utf-8"); } catch (Exception e) { Log.e("MyTools", Log.getStackTraceString(e)); } return device; }
From source file:com.dm.material.dashboard.candybar.fragments.FAQsFragment.java
private void getFAQs() { mGetFAQs = new AsyncTask<Void, Void, Boolean>() { List<FAQs> faqs;//from ww w . j a v a 2s . c o m String[] questions; String[] answers; @Override protected void onPreExecute() { super.onPreExecute(); faqs = new ArrayList<>(); questions = getActivity().getResources().getStringArray(R.array.questions); answers = getActivity().getResources().getStringArray(R.array.answers); } @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); for (int i = 0; i < questions.length; i++) { if (i < answers.length) { FAQs faq = new FAQs(questions[i], answers[i]); faqs.add(faq); } } 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) { setHasOptionsMenu(true); mAdapter = new FAQsAdapter(faqs); mRecyclerView.setAdapter(mAdapter); } mGetFAQs = null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.dm.material.dashboard.candybar.helpers.IconsHelper.java
public static void prepareIconsList(@NonNull Context context) { new AsyncTask<Void, Void, Boolean>() { Home home = null;// w ww . j av a 2s .co m @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); if (CandyBarMainActivity.sSections == null) { CandyBarMainActivity.sSections = IconsHelper.getIconsList(context); int count = 0; for (Icon section : CandyBarMainActivity.sSections) { count += section.getIcons().size(); } CandyBarMainActivity.sIconsCount = count; } for (int i = 0; i < CandyBarMainActivity.sSections.size(); i++) { List<Icon> icons = CandyBarMainActivity.sSections.get(i).getIcons(); if (context.getResources().getBoolean(R.bool.show_icon_name)) { for (Icon icon : icons) { boolean replacer = context.getResources() .getBoolean(R.bool.enable_icon_name_replacer); String name = replaceName(context, replacer, icon.getTitle()); icon.setTitle(name); } } if (context.getResources().getBoolean(R.bool.enable_icons_sort)) { Collections.sort(icons, new AlphanumComparator() { @Override public int compare(Object o1, Object o2) { String s1 = ((Icon) o1).getTitle(); String s2 = ((Icon) o2).getTitle(); return super.compare(s1, s2); } }); CandyBarMainActivity.sSections.get(i).setIcons(icons); } } if (CandyBarMainActivity.sHomeIcon != null) return true; Random random = new Random(); int index = random.nextInt(CandyBarMainActivity.sSections.size()); List<Icon> icons = CandyBarMainActivity.sSections.get(index).getIcons(); index = random.nextInt(icons.size()); Icon icon = icons.get(index); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(context.getResources(), icon.getRes(), options); if (!context.getResources().getBoolean(R.bool.show_icon_name)) { String name = replaceName(context, true, icon.getTitle()); icon.setTitle(name); } home = new Home(icon.getRes(), icon.getTitle(), String.format(context.getResources().getString(R.string.home_icon_dimension), options.outWidth + " x " + options.outHeight), Home.Type.DIMENSION); CandyBarMainActivity.sHomeIcon = home; 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) { if (home == null) return; if (context == null) return; FragmentManager fm = ((AppCompatActivity) context).getSupportFragmentManager(); if (fm == null) return; Fragment fragment = fm.findFragmentByTag("home"); if (fragment == null) return; HomeListener listener = (HomeListener) fragment; listener.onHomeDataUpdated(home); } } }.execute(); }
From source file:fr.eyal.lib.data.service.DataLibService.java
@SuppressWarnings("unchecked") @Override//from w ww .j av a2s. c o m protected void onHandleIntent(final Intent intent) { final int processorType = intent.getIntExtra(INTENT_EXTRA_PROCESSOR_TYPE, -1); Out.d(TAG, "onHandleIntent"); // String userAgent = intent.getStringExtra(INTENT_EXTRA_USER_AGENT); final DataLibRequest request = new DataLibRequest(); DataLibWebConfig.applyToRequest(request, DataLibWebConfig.getInstance()); //we apply a default configuration for the request //we get the action data request.url = intent.getStringExtra(INTENT_EXTRA_URL); request.params = intent.getParcelableExtra(INTENT_EXTRA_PARAMS); request.parseType = intent.getIntExtra(INTENT_EXTRA_PARSE_TYPE, DataLibRequest.PARSE_TYPE_SAX_XML); //we eventually add the complex options Object complexOptions = intent.getSerializableExtra(INTENT_EXTRA_COMPLEX_OPTIONS); if (complexOptions instanceof ComplexOptions) request.complexOptions = (ComplexOptions) complexOptions; request.context = getApplicationContext(); //we get the options to apply int option = intent.getIntExtra(INTENT_EXTRA_REQUEST_OPTION, DataLibRequest.OPTION_NO_OPTION); DataLibWebConfig.applyToRequest(request, option, true); //we add the intent request.intent = intent; try { if (processorType == COOKIES_FLUSH) this.flushCookies(); else { //we launch the processor on a daughter class launchProcessor(processorType, request); } } catch (final Exception e) { Out.e(TAG, "Erreur", e); final BusinessResponse response = new BusinessResponse(); response.status = BusinessResponse.STATUS_ERROR; response.statusMessage = Log.getStackTraceString(e); sendResult(request, response, response.status); } }
From source file:org.alfresco.mobile.android.application.fragments.signin.AccountSignInFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mdmManager = MDMManager.getInstance(getActivity()); if (getArguments() != null || !getArguments().isEmpty()) { account = (AlfrescoAccount) getArguments().getSerializable(ARGUMENT_ACCOUNT); usernameIntent = getArguments().getString(ARGUMENT_USERNAME); alfrescoUrlIntent = getArguments().getString(ARGUMENT_REPO_URL); shareUrlIntent = getArguments().getString(ARGUMENT_SHARE_URL); hasIntentConfig = !TextUtils.isEmpty(alfrescoUrlIntent) && !TextUtils.isEmpty(usernameIntent); }/* ww w . j a va 2 s. co m*/ getActivity().setTitle(R.string.app_name); setRootView(inflater.inflate(R.layout.fr_signin, container, false)); Button validate = (Button) viewById(R.id.next); validate.setEnabled(true); validate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { validateServer(v); } }); userField = (MaterialEditText) viewById(R.id.signin_username); userField.setEnabled(false); userField.setHint(R.string.account_username); if (account != null) { userField.setText(account.getUsername()); } else if (hasIntentConfig) { userField.setText(usernameIntent); } else { userField.setText(MDMManager.getInstance(getActivity()).getUsername()); } try { passwordField = (MaterialEditText) viewById(R.id.signin_password); passwordField.setHint(R.string.account_password); passwordField.requestFocus(); UIUtils.showKeyboard(getActivity(), passwordField); } catch (Exception e) { Log.e("ERROR", Log.getStackTraceString(e)); } // Accessibility if (AccessibilityUtils.isEnabled(getActivity())) { userField.setHint(getString(R.string.account_username_required_hint)); passwordField.setHint(getString(R.string.account_password_required_hint)); } return getRootView(); }
From source file:com.nbzs.ningbobus.ui.loaders.BusRunInfoReaderLoader.java
public List<BusLineRunInfoItem> loadInBackground() { Log.d(TAG, "loading URI: " + mFeedUri); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getContext()); String selectedBusLines = prefs.getString("SelectedBusLines", ""); String[] selected = selectedBusLines.split(","); List<Integer> busLines = new ArrayList<Integer>(); for (int i = 0; i < selected.length; ++i) { try {// w w w .jav a 2 s . com busLines.add(Integer.parseInt(selected[i])); } catch (NumberFormatException e) { } } Calendar cal = Calendar.getInstance(); cal.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); Log.i(TAG, "start read feed at" + sdf.format(cal.getTime())); final List<BusLineRunInfoItem> items = Collections.synchronizedList(new ArrayList<BusLineRunInfoItem>()); Thread[] threads = new Thread[busLines.size()]; for (int i = 0; i < busLines.size(); ++i) { final int idx = busLines.get(i); threads[i] = new Thread(new Runnable() { public void run() { BusLineRunInfoItem item = downloadOneFeedItem(idx); synchronized (items) { if (item != null) { items.add(item); } } } }); threads[i].start(); } try { for (Thread thread : threads) { thread.join(); } } catch (InterruptedException e) { Log.d(TAG, "this should not happen"); Log.d(TAG, Log.getStackTraceString(e)); } cal.getTime(); Log.i(TAG, "end read feed at" + sdf.format(cal.getTime())); return items; }
From source file:com.example.android.activityrecognition.CreateMapActivity.java
/** * Draw user and car markers on Map//from w w w. java2 s . co m */ private void drawMarker(LatLng point, String markertitle) { try { // Creating MarkerOptions MarkerOptions options = new MarkerOptions(); // Setting the position of the marker options.position(point); /** * For the User location, the color of marker is GREEN and for the * Car location, the color of marker is RED. */ options.title(markertitle); if (markertitle.equals("Car Location")) { options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); } else if (markertitle.equals("Me")) { options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); } // Add new marker to the Google Map Android API V2 mMap.addMarker(options); } catch (Exception e) { Log.e("Create Map's", point.toString()); Log.e("Create Map's", Log.getStackTraceString(e)); } }
From source file:com.dm.material.dashboard.candybar.adapters.IntentAdapter.java
private void sendRequest(ComponentName name) { try {/*from w ww . j a v a 2 s . c om*/ Intent intent = new Intent(Intent.ACTION_SEND); intent = addIntentExtra(intent); intent.setComponent(name); intent.addCategory(Intent.CATEGORY_LAUNCHER); mContext.startActivity(intent); } catch (IllegalArgumentException e) { try { Intent intent = new Intent(Intent.ACTION_SEND); intent = addIntentExtra(intent); mContext.startActivity( Intent.createChooser(intent, mContext.getResources().getString(R.string.email_client))); } catch (ActivityNotFoundException e1) { LogUtil.e(Log.getStackTraceString(e1)); } } }
From source file:eu.faircode.netguard.ActivityPro.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "Create"); Util.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.pro);//from www . j ava 2 s . c o m getSupportActionBar().setTitle(R.string.title_pro); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); // Initial state updateState(); TextView tvLogTitle = findViewById(R.id.tvLogTitle); TextView tvFilterTitle = findViewById(R.id.tvFilterTitle); TextView tvNotifyTitle = findViewById(R.id.tvNotifyTitle); TextView tvSpeedTitle = findViewById(R.id.tvSpeedTitle); TextView tvThemeTitle = findViewById(R.id.tvThemeTitle); TextView tvAllTitle = findViewById(R.id.tvAllTitle); TextView tvDev1Title = findViewById(R.id.tvDev1Title); TextView tvDev2Title = findViewById(R.id.tvDev2Title); Linkify.TransformFilter filter = new Linkify.TransformFilter() { @Override public String transformUrl(Matcher match, String url) { return ""; } }; Linkify.addLinks(tvLogTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_LOG, null, filter); Linkify.addLinks(tvFilterTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_FILTER, null, filter); Linkify.addLinks(tvNotifyTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_NOTIFY, null, filter); Linkify.addLinks(tvSpeedTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SPEED, null, filter); Linkify.addLinks(tvThemeTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_THEME, null, filter); Linkify.addLinks(tvAllTitle, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_PRO1, null, filter); Linkify.addLinks(tvDev1Title, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SUPPORT1, null, filter); Linkify.addLinks(tvDev2Title, Pattern.compile(".*"), "http://www.netguard.me/#" + SKU_SUPPORT2, null, filter); String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); String challenge = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? Build.SERIAL : "O3" + android_id); String seed = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "NetGuard2" : "NetGuard3"); // Challenge TextView tvChallenge = findViewById(R.id.tvChallenge); tvChallenge.setText(challenge); // Response try { final String response = Util.md5(challenge, seed); EditText etResponse = findViewById(R.id.etResponse); etResponse.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Do nothing } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Do nothing } @Override public void afterTextChanged(Editable editable) { if (response.equals(editable.toString().toUpperCase())) { IAB.setBought(SKU_DONATION, ActivityPro.this); updateState(); } } }); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } try { iab = new IAB(new IAB.Delegate() { @Override public void onReady(final IAB iab) { Log.i(TAG, "IAB ready"); try { iab.updatePurchases(); updateState(); final Button btnLog = findViewById(R.id.btnLog); final Button btnFilter = findViewById(R.id.btnFilter); final Button btnNotify = findViewById(R.id.btnNotify); final Button btnSpeed = findViewById(R.id.btnSpeed); final Button btnTheme = findViewById(R.id.btnTheme); final Button btnAll = findViewById(R.id.btnAll); final Button btnDev1 = findViewById(R.id.btnDev1); final Button btnDev2 = findViewById(R.id.btnDev2); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { try { int id = 0; PendingIntent pi = null; if (view == btnLog) { id = SKU_LOG_ID; pi = iab.getBuyIntent(SKU_LOG, false); } else if (view == btnFilter) { id = SKU_FILTER_ID; pi = iab.getBuyIntent(SKU_FILTER, false); } else if (view == btnNotify) { id = SKU_NOTIFY_ID; pi = iab.getBuyIntent(SKU_NOTIFY, false); } else if (view == btnSpeed) { id = SKU_SPEED_ID; pi = iab.getBuyIntent(SKU_SPEED, false); } else if (view == btnTheme) { id = SKU_THEME_ID; pi = iab.getBuyIntent(SKU_THEME, false); } else if (view == btnAll) { id = SKU_PRO1_ID; pi = iab.getBuyIntent(SKU_PRO1, false); } else if (view == btnDev1) { id = SKU_SUPPORT1_ID; pi = iab.getBuyIntent(SKU_SUPPORT1, true); } else if (view == btnDev2) { id = SKU_SUPPORT2_ID; pi = iab.getBuyIntent(SKU_SUPPORT2, true); } if (id > 0 && pi != null) startIntentSenderForResult(pi.getIntentSender(), id, new Intent(), 0, 0, 0); } catch (Throwable ex) { Log.i(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } }; btnLog.setOnClickListener(listener); btnFilter.setOnClickListener(listener); btnNotify.setOnClickListener(listener); btnSpeed.setOnClickListener(listener); btnTheme.setOnClickListener(listener); btnAll.setOnClickListener(listener); btnDev1.setOnClickListener(listener); btnDev2.setOnClickListener(listener); btnLog.setEnabled(true); btnFilter.setEnabled(true); btnNotify.setEnabled(true); btnSpeed.setEnabled(true); btnTheme.setEnabled(true); btnAll.setEnabled(true); btnDev1.setEnabled(true); btnDev2.setEnabled(true); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } }, this); iab.bind(); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:org.opendatakit.logging.WebLoggerImpl.java
private synchronized void log(String logMsg) throws IOException { String curDateStamp = getFormattedFileDateNow(); if (logFile == null || dateStamp == null || !curDateStamp.equals(dateStamp)) { // the file we should log to has changed. // or has not yet been opened. if (logFile != null) { // close existing writer... OutputStreamWriter writer = logFile; logFile = null;//w ww . j a v a 2 s. com try { writer.close(); } catch (IOException e) { Log.e(TAG, Log.getStackTraceString(e), e); } } // ensure we have the directories created... try { ODKFileUtils.verifyExternalStorageAvailability(); ODKFileUtils.assertDirectoryStructure(appName); } catch (Exception e) { Log.e(TAG, "Unable to create logging directory"); Log.e(TAG, Log.getStackTraceString(e), e); return; } String loggingPath = ODKFileUtils.getLoggingFolder(appName); File loggingDirectory = new File(loggingPath); if (!loggingDirectory.isDirectory()) { Log.e(TAG, "Logging Directory exists but is not a directory!"); return; } if (loggingObserver == null) { loggingObserver = new LoggingFileObserver(loggingDirectory.getAbsolutePath()); } File f = new File(loggingDirectory, curDateStamp + ".log"); try { FileOutputStream fo = new FileOutputStream(f, true); logFile = new OutputStreamWriter(new BufferedOutputStream(fo), CharEncoding.UTF_8); dateStamp = curDateStamp; // if we see a lot of these being logged, we have a problem logFile.write("---- starting ----\n"); } catch (Exception e) { Log.e(TAG, "Unexpected exception while opening logfile: " + Log.getStackTraceString(e), e); try { if (logFile != null) { logFile.close(); } } catch (Exception ignored) { // ignore } logFile = null; return; } } if (logFile != null) { logFile.write(logMsg + "\n"); } if (lastFlush + WebLoggerImpl.FLUSH_INTERVAL < System.currentTimeMillis()) { // log when we are explicitly flushing, just to have a record of that in // the log logFile.write("---- flushing ----\n"); logFile.flush(); lastFlush = System.currentTimeMillis(); } }