List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:org.alfresco.mobile.android.application.accounts.AccountManager.java
public static List<Account> retrieveAccounts(Context context) { List<Account> accounts = new ArrayList<Account>(); try {//from www.j a v a 2s . c o m Cursor cursor = context.getContentResolver().query(CONTENT_URI, COLUMN_ALL, null, null, null); accounts = new ArrayList<Account>(cursor.getCount()); while (cursor.moveToNext()) { accounts.add(createAccountWithoutClose(cursor)); } //Log.d(TAG, "accounts " + accounts.size()); cursor.close(); } catch (Exception e) { Log.d(TAG, Log.getStackTraceString(e)); } return accounts; }
From source file:android_network.hetnet.vpn_service.AdapterLog.java
public AdapterLog(Context context, Cursor cursor, boolean resolve, boolean organization) { super(context, cursor, 0); this.resolve = resolve; this.organization = organization; colID = cursor.getColumnIndex("ID"); colTime = cursor.getColumnIndex("time"); colVersion = cursor.getColumnIndex("version"); colProtocol = cursor.getColumnIndex("protocol"); colFlags = cursor.getColumnIndex("flags"); colSAddr = cursor.getColumnIndex("saddr"); colSPort = cursor.getColumnIndex("sport"); colDAddr = cursor.getColumnIndex("daddr"); colDPort = cursor.getColumnIndex("dport"); colDName = cursor.getColumnIndex("dname"); colUid = cursor.getColumnIndex("uid"); colData = cursor.getColumnIndex("data"); colAllowed = cursor.getColumnIndex("allowed"); colConnection = cursor.getColumnIndex("connection"); colInteractive = cursor.getColumnIndex("interactive"); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorOn, tv, true); colorOn = tv.data;// www . ja va 2 s .co m context.getTheme().resolveAttribute(R.attr.colorOff, tv, true); colorOff = tv.data; iconSize = Util.dips2pixels(24, context); try { List<InetAddress> lstDns = ServiceSinkhole.getDns(context); dns1 = (lstDns.size() > 0 ? lstDns.get(0) : null); dns2 = (lstDns.size() > 1 ? lstDns.get(1) : null); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1")); vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1")); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:com.summer.logger.LoggerPrinter.java
@Override public void e(Throwable throwable, String message, Object... args) { if (throwable != null && message != null) { message += " : " + Log.getStackTraceString(throwable); }/*from w w w .j a v a 2s . c o m*/ if (throwable != null && message == null) { message = throwable.toString(); } if (message == null) { message = "No message/exception is set"; } log(ERROR, message, args); }
From source file:io.v.syncslides.FullscreenSlideFragment.java
private void handleError(String msg, Throwable throwable) { Log.e(TAG, msg + ": " + Log.getStackTraceString(throwable)); Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show(); }
From source file:com.dm.wallpaper.board.fragments.dialogs.LanguagesFragment.java
private void getLanguages() { mGetLanguages = new AsyncTask<Void, Void, Boolean>() { List<Language> languages; int index = 0; @Override/*from w w w . j ava 2s. co m*/ protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); languages = LocaleHelper.getAvailableLanguages(getActivity()); Locale locale = Preferences.get(getActivity()).getCurrentLocale(); for (int i = 0; i < languages.size(); i++) { Locale l = languages.get(i).getLocale(); if (l.toString().equals(locale.toString())) { index = i; 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) { mListView.setAdapter(new LanguagesAdapter(getActivity(), languages, index)); } else { dismiss(); } mGetLanguages = null; } }.execute(); }
From source file:org.alfresco.mobile.android.application.fragments.site.request.JoinSiteRequestsFragment.java
@Subscribe public void onCancelPendingMembershipEvent(CancelPendingMembershipEvent event) { int messageId = R.string.error_general; if (!event.hasException) { Site joinSiteRequest = event.data; messageId = R.string.action_cancel_join_site_request; remove(joinSiteRequest);//from ww w .j ava 2 s. c o m } else { Log.w(TAG, Log.getStackTraceString(event.exception)); } AlfrescoNotificationManager.getInstance(getActivity()) .showLongToast(String.format(getString(messageId), event.oldSite.getShortName())); }
From source file:net.olejon.mdapp.MyTools.java
public String getProjectVersionName() { String name = "0.0"; try {//from w w w.j av a2s. c om name = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName; } catch (Exception e) { Log.e("MyTools", Log.getStackTraceString(e)); } return name; }
From source file:net.olejon.mdapp.ClinicalTrialsCardsAdapter.java
@Override public void onBindViewHolder(ClinicalTrialsViewHolder viewHolder, int i) { try {//from w w w . j a v a 2s. co m final JSONObject clinicalTrialsJsonObject = mClinicalTrials.getJSONObject(i); final String title = clinicalTrialsJsonObject.getString("study"); final String status = clinicalTrialsJsonObject.getString("status"); final String conditions = clinicalTrialsJsonObject.getString("conditions"); final String intervention = clinicalTrialsJsonObject.getString("intervention"); final String uri = clinicalTrialsJsonObject.getString("uri"); viewHolder.title.setText(title); viewHolder.status.setText(status); viewHolder.conditions.setText(conditions); viewHolder.intervention.setText(intervention); viewHolder.title.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", title); intent.putExtra("uri", uri); mContext.startActivity(intent); } }); viewHolder.button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", title); intent.putExtra("uri", uri); mContext.startActivity(intent); } }); animateView(viewHolder.card, i); } catch (Exception e) { Log.e("ClinicalTrialsCards", Log.getStackTraceString(e)); } }
From source file:eu.faircode.adblocker.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);//from w w w . java 2 s. co m if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }