List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:org.alfresco.mobile.android.application.fragments.node.details.PagerNodeDetailsFragment.java
@Subscribe public void onDocumentUpdated(UpdateNodeEvent event) { try {/*from w w w . j a va2s . c om*/ super.onDocumentUpdated(event); } catch (Exception e) { Log.e(TAG, Log.getStackTraceString(e)); } }
From source file:net.olejon.spotcommander.DonateActivity.java
private void consumeDonation(final String purchaseToken) { try {//from www .j av a 2 s. c o m mIInAppBillingService.consumePurchase(3, getPackageName(), purchaseToken); } catch (Exception e) { mTools.showToast(getString(R.string.donate_something_went_wrong), 1); Log.e("DonateActivity", Log.getStackTraceString(e)); } }
From source file:eu.faircode.netguard.SinkholeService.java
private ParcelFileDescriptor startVPN() { Log.i(TAG, "Starting"); // Check state boolean metered = Util.isMetered(this); boolean wifi = Util.isWifiActive(this); boolean roaming = Util.isRoaming(this); boolean interactive = Util.isInteractive(this); Log.i(TAG, "metered=" + metered + " wifi=" + wifi + " roaming=" + roaming + " interactive=" + interactive); // Build VPN service final Builder builder = new Builder(); builder.setSession(getString(R.string.app_name)); builder.addAddress("10.1.10.1", 32); builder.addAddress("fd00:1:fd00:1:fd00:1:fd00:1", 64); builder.addRoute("0.0.0.0", 0); builder.addRoute("0:0:0:0:0:0:0:0", 0); // Add list of allowed applications for (Rule rule : Rule.getRules(true, TAG, this)) { boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked); if ((!blocked || (rule.unused && interactive)) && (!metered || !(rule.roaming && roaming))) { if (debug) Log.i(TAG, "Allowing " + rule.info.packageName); try { builder.addDisallowedApplication(rule.info.packageName); } catch (PackageManager.NameNotFoundException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); }/*w w w . j a va 2 s . com*/ } } // Build configure intent Intent configure = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, configure, PendingIntent.FLAG_UPDATE_CURRENT); builder.setConfigureIntent(pi); if (debug) builder.setBlocking(true); // Start VPN service try { return builder.establish(); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); // Disable firewall SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putBoolean("enabled", false).apply(); // Feedback Util.toast(ex.toString(), Toast.LENGTH_LONG, this); Widget.updateWidgets(this); return null; } }
From source file:com.binaryelysium.mp3tunes.api.Locker.java
private void refreshSessionImpl(String username, String password, HttpClient client) throws LockerException, LoginException { Log.w("Mp3Tunes", "Called refresh session"); try {// w w w .j a v a 2 s . co m HttpClientCaller caller = HttpClientCaller.getInstance(); RemoteMethod method = new RemoteMethod.Builder(RemoteMethod.METHODS.LOGIN) .addParam("username", username).addParam("password", password).create(); String response; if (client != null) { response = caller.call(method, client); } else { response = caller.call(method); } try { LockerContext.instance().setSession(Session.sessionFromJson(response)); } catch (JSONException e) { throw new LockerException("Server returned corrupt data"); } } catch (IllegalArgumentException e) { throw new LoginException(); } catch (HttpResponseException e) { Log.w("Mp3Tunes", "Error code: " + Integer.toString(e.getStatusCode()) + "\n" + Log.getStackTraceString(e)); throw new LockerException("connection issue"); } catch (IOException e) { Log.w("Mp3Tunes", Log.getStackTraceString(e)); throw new LockerException("connection issue"); } catch (InvalidSessionException e) { throw new LoginException(); } }
From source file:org.alfresco.mobile.android.application.fragments.signin.AccountOAuthFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = super.onCreateView(inflater, container, savedInstanceState); setOnOAuthAccessTokenListener(new OnOAuthAccessTokenListener() { @Override//from w w w . ja v a 2 s .co m public void failedRequestAccessToken(Exception e) { retryOAuthAuthentication(); Log.e(TAG, Log.getStackTraceString(e)); } @Override public void beforeRequestAccessToken(Bundle b) { if (getActivity() instanceof BaseActivity) { ((BaseActivity) getActivity()).displayWaitingDialog(); } } @Override public void afterRequestAccessToken(OAuthData result) { load(result); } }); final View waiting = v.findViewById(R.id.waiting); setOnOAuthWebViewListener(new OnOAuthWebViewListener() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { } @Override public void onPageFinished(WebView view, String url) { if (url.startsWith(callback.replace("http", "https"))) { if (waiting != null) { waiting.setVisibility(View.VISIBLE); } view.setVisibility(View.GONE); } else if (OAuthConstant.PUBLIC_API_OAUTH_AUTHORIZE_URL.equals(url)) { retryOAuthAuthentication(); if (waiting != null) { waiting.setVisibility(View.VISIBLE); } view.setVisibility(View.GONE); } else { if (waiting != null) { waiting.setVisibility(View.GONE); } view.setVisibility(View.VISIBLE); } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { waiting.setVisibility(View.VISIBLE); } }); return v; }
From source file:com.dm.material.dashboard.candybar.helpers.DrawableHelper.java
@Nullable public static Bitmap getHighQualityIcon(@NonNull Context context, String packageName) { try {//from w w w . j a va 2 s . c o m PackageManager packageManager = context.getPackageManager(); ApplicationInfo info = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA); Resources resources = packageManager.getResourcesForApplication(packageName); int density = DisplayMetrics.DENSITY_XXHIGH; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { density = DisplayMetrics.DENSITY_XXXHIGH; } Drawable drawable = ResourcesCompat.getDrawableForDensity(resources, info.icon, density, null); if (drawable != null) return ((BitmapDrawable) drawable).getBitmap(); } catch (Exception | OutOfMemoryError e) { LogUtil.e(Log.getStackTraceString(e)); } return null; }
From source file:com.dm.material.dashboard.candybar.fragments.dialog.AboutFragment.java
@Override public void onClick(View view) { int id = view.getId(); Intent intent = null;/*w ww .j a va2 s . c om*/ if (id == R.id.email) { try { final Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getActivity().getResources().getString(R.string.about_email), null)); email.putExtra(Intent.EXTRA_SUBJECT, (getActivity().getResources().getString(R.string.app_name))); getActivity().startActivity( Intent.createChooser(email, getActivity().getResources().getString(R.string.email_client))); dismiss(); } catch (ActivityNotFoundException e) { Log.d(Tag.LOG_TAG, Log.getStackTraceString(e)); } return; } else if (id == R.id.link1) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getActivity().getResources().getString(R.string.about_link_1_url))); } else if (id == R.id.link2) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getActivity().getResources().getString(R.string.about_link_2_url))); } else if (id == R.id.dev_link1) { intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getActivity().getResources().getString(R.string.about_dashboard_dev_github_url))); } else if (id == R.id.dev_link2) { intent = new Intent(Intent.ACTION_VIEW, Uri .parse(getActivity().getResources().getString(R.string.about_dashboard_dev_google_plus_url))); } try { getActivity().startActivity(intent); } catch (ActivityNotFoundException e) { Log.d(Tag.LOG_TAG, Log.getStackTraceString(e)); } }
From source file:com.dm.material.dashboard.candybar.tasks.IconsLoaderTask.java
@Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try {//from w w w. ja va 2s . c o m Thread.sleep(1); if (CandyBarMainActivity.sSections == null) { CandyBarMainActivity.sSections = IconsHelper.getIconsList(mContext.get()); for (int i = 0; i < CandyBarMainActivity.sSections.size(); i++) { List<Icon> icons = CandyBarMainActivity.sSections.get(i).getIcons(); if (mContext.get().getResources().getBoolean(R.bool.show_icon_name) || mContext.get().getResources().getBoolean(R.bool.enable_icon_name_replacer)) { for (Icon icon : icons) { boolean replacer = mContext.get().getResources() .getBoolean(R.bool.enable_icon_name_replacer); String name = IconsHelper.replaceName(mContext.get(), replacer, icon.getTitle()); icon.setTitle(name); } } if (mContext.get().getResources().getBoolean(R.bool.enable_icons_sort) || mContext.get().getResources().getBoolean(R.bool.enable_icon_name_replacer)) { 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 (CandyBarApplication.getConfiguration().isShowTabAllIcons()) { List<Icon> icons = IconsHelper.getTabAllIcons(); CandyBarMainActivity.sSections .add(new Icon(CandyBarApplication.getConfiguration().getTabAllIconsTitle(), 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(mContext.get().getResources(), icon.getRes(), options); if (!mContext.get().getResources().getBoolean(R.bool.show_icon_name)) { String name = IconsHelper.replaceName(mContext.get(), true, icon.getTitle()); icon.setTitle(name); } mHome = new Home(icon.getRes(), icon.getTitle(), String.format(mContext.get().getResources().getString(R.string.home_icon_dimension), options.outWidth + " x " + options.outHeight), Home.Type.DIMENSION); CandyBarMainActivity.sHomeIcon = mHome; return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; }
From source file:org.alfresco.mobile.android.application.accounts.fragment.AccountOAuthFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getDialog() != null) { getDialog().setTitle(R.string.account_wizard_step2_title); getDialog().requestWindowFeature(Window.FEATURE_LEFT_ICON); } else {/* w ww.ja v a 2 s. c om*/ UIUtils.displayTitle(getActivity(), R.string.account_wizard_step2_title, !(getActivity() instanceof HomeScreenActivity)); } final View v = super.onCreateView(inflater, container, savedInstanceState); setOnOAuthAccessTokenListener(new OnOAuthAccessTokenListener() { @Override public void failedRequestAccessToken(Exception e) { if (DisplayUtils.hasCentralPane(getActivity())) { ((MainActivity) getActivity()).clearScreen(); } else { getActivity().getFragmentManager().popBackStack(); } Log.e(TAG, Log.getStackTraceString(e)); MessengerManager.showLongToast(getActivity(), getActivity().getString(R.string.error_general)); } @Override public void beforeRequestAccessToken(Bundle b) { int operationId = CreateAccountRequest.TYPE_ID; String intentId = IntentIntegrator.ACTION_CREATE_ACCOUNT_COMPLETED; if (getArguments().containsKey(PARAM_ACCOUNT)) { operationId = LoadSessionRequest.TYPE_ID; intentId = IntentIntegrator.ACTION_LOAD_ACCOUNT_COMPLETED; } if (getFragmentManager().findFragmentByTag(OperationWaitingDialogFragment.TAG) == null) { // Create Account + Session OperationWaitingDialogFragment .newInstance(intentId, operationId, R.drawable.ic_cloud, getString(R.string.wait_title), getString(R.string.wait_message), null, 0) .show(getFragmentManager(), OperationWaitingDialogFragment.TAG); } } @Override public void afterRequestAccessToken(OAuthData result) { load(result); } }); final View waiting = v.findViewById(R.id.waiting); setOnOAuthWebViewListener(new OnOAuthWebViewListener() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { } @Override public void onPageFinished(WebView view, String url) { if (waiting != null) { waiting.setVisibility(View.GONE); } view.setVisibility(View.VISIBLE); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { waiting.setVisibility(View.VISIBLE); } }); return v; }
From source file:eu.faircode.netguard.ActivityLog.java
@Override protected void onCreate(Bundle savedInstanceState) { Util.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.logging);/* w ww. j a v a 2 s. com*/ running = true; // Action bar View actionView = getLayoutInflater().inflate(R.layout.actionlog, null, false); SwitchCompat swEnabled = actionView.findViewById(R.id.swEnabled); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); getSupportActionBar().setTitle(R.string.menu_log); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get settings final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); resolve = prefs.getBoolean("resolve", false); organization = prefs.getBoolean("organization", false); boolean log = prefs.getBoolean("log", false); // Show disabled message TextView tvDisabled = findViewById(R.id.tvDisabled); tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE); // Set enabled switch swEnabled.setChecked(log); swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { prefs.edit().putBoolean("log", isChecked).apply(); } }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); lvLog = findViewById(R.id.lvLog); boolean udp = prefs.getBoolean("proto_udp", true); boolean tcp = prefs.getBoolean("proto_tcp", true); boolean other = prefs.getBoolean("proto_other", true); boolean allowed = prefs.getBoolean("traffic_allowed", true); boolean blocked = prefs.getBoolean("traffic_blocked", true); adapter = new AdapterLog(this, DatabaseHelper.getInstance(this).getLog(udp, tcp, other, allowed, blocked), resolve, organization); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return DatabaseHelper.getInstance(ActivityLog.this).searchLog(constraint.toString()); } }); lvLog.setAdapter(adapter); try { 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)); } lvLog.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { PackageManager pm = getPackageManager(); Cursor cursor = (Cursor) adapter.getItem(position); long time = cursor.getLong(cursor.getColumnIndex("time")); int version = cursor.getInt(cursor.getColumnIndex("version")); int protocol = cursor.getInt(cursor.getColumnIndex("protocol")); final String saddr = cursor.getString(cursor.getColumnIndex("saddr")); final int sport = (cursor.isNull(cursor.getColumnIndex("sport")) ? -1 : cursor.getInt(cursor.getColumnIndex("sport"))); final String daddr = cursor.getString(cursor.getColumnIndex("daddr")); final int dport = (cursor.isNull(cursor.getColumnIndex("dport")) ? -1 : cursor.getInt(cursor.getColumnIndex("dport"))); final String dname = cursor.getString(cursor.getColumnIndex("dname")); final int uid = (cursor.isNull(cursor.getColumnIndex("uid")) ? -1 : cursor.getInt(cursor.getColumnIndex("uid"))); int allowed = (cursor.isNull(cursor.getColumnIndex("allowed")) ? -1 : cursor.getInt(cursor.getColumnIndex("allowed"))); // Get external address InetAddress addr = null; try { addr = InetAddress.getByName(daddr); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } String ip; int port; if (addr.equals(vpn4) || addr.equals(vpn6)) { ip = saddr; port = sport; } else { ip = daddr; port = dport; } // Build popup menu PopupMenu popup = new PopupMenu(ActivityLog.this, findViewById(R.id.vwPopupAnchor)); popup.inflate(R.menu.log); // Application name if (uid >= 0) popup.getMenu().findItem(R.id.menu_application) .setTitle(TextUtils.join(", ", Util.getApplicationNames(uid, ActivityLog.this))); else popup.getMenu().removeItem(R.id.menu_application); // Destination IP popup.getMenu().findItem(R.id.menu_protocol) .setTitle(Util.getProtocolName(protocol, version, false)); // Whois final Intent lookupIP = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.tcpiputils.com/whois-lookup/" + ip)); if (pm.resolveActivity(lookupIP, 0) == null) popup.getMenu().removeItem(R.id.menu_whois); else popup.getMenu().findItem(R.id.menu_whois).setTitle(getString(R.string.title_log_whois, ip)); // Lookup port final Intent lookupPort = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.speedguide.net/port.php?port=" + port)); if (port <= 0 || pm.resolveActivity(lookupPort, 0) == null) popup.getMenu().removeItem(R.id.menu_port); else popup.getMenu().findItem(R.id.menu_port).setTitle(getString(R.string.title_log_port, port)); if (!prefs.getBoolean("filter", false)) { popup.getMenu().removeItem(R.id.menu_allow); popup.getMenu().removeItem(R.id.menu_block); } final Packet packet = new Packet(); packet.version = version; packet.protocol = protocol; packet.daddr = daddr; packet.dport = dport; packet.time = time; packet.uid = uid; packet.allowed = (allowed > 0); // Time popup.getMenu().findItem(R.id.menu_time) .setTitle(SimpleDateFormat.getDateTimeInstance().format(time)); // Handle click popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_application: { Intent main = new Intent(ActivityLog.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main); return true; } case R.id.menu_whois: startActivity(lookupIP); return true; case R.id.menu_port: startActivity(lookupPort); return true; case R.id.menu_allow: if (IAB.isPurchased(ActivityPro.SKU_FILTER, ActivityLog.this)) { DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 0); ServiceSinkhole.reload("allow host", ActivityLog.this, false); Intent main = new Intent(ActivityLog.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main); } else startActivity(new Intent(ActivityLog.this, ActivityPro.class)); return true; case R.id.menu_block: if (IAB.isPurchased(ActivityPro.SKU_FILTER, ActivityLog.this)) { DatabaseHelper.getInstance(ActivityLog.this).updateAccess(packet, dname, 1); ServiceSinkhole.reload("block host", ActivityLog.this, false); Intent main = new Intent(ActivityLog.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); startActivity(main); } else startActivity(new Intent(ActivityLog.this, ActivityPro.class)); return true; default: return false; } } }); // Show popup.show(); } }); live = true; }