List of usage examples for android.util Log getStackTraceString
public static String getStackTraceString(Throwable tr)
From source file:org.apache.cordova.plugins.Actionable.java
public static Actionable fromJSON(JSONObject jsobj) { try {// w w w . j a v a2s . c om Actionable action = new Actionable(); action.mTitle = jsobj.getString("label"); action.mDisabled = jsobj.optBoolean("disabled", false); action.mSelected = jsobj.optBoolean("selected", false); action.mCallbackId = jsobj.optString("callback"); String iconname = jsobj.optString("icon", null); if (iconname != null) { try { String tmp_uri = "www/" + iconname; InputStream image = sAssetMgr.open(tmp_uri); action.mIcon = Drawable.createFromStream(image, iconname); } catch (IOException e) { } } return action; } catch (JSONException e) { Log.v("Cambie", Log.getStackTraceString(e)); return null; } }
From source file:info.papdt.blacklight.api.friendships.GroupsApi.java
public static MessageListModel fetchGroupTimeLine(String groupId, int count, int page) { WeiboParameters params = new WeiboParameters(); params.put("list_id", groupId); params.put("count", count); params.put("page", page); try {//from w ww . jav a 2 s .c om JSONObject json = request(Constants.FRIENDSHIPS_GROUPS_TIMELINE, params, HTTP_GET); return new Gson().fromJson(json.toString(), MessageListModel.class); } catch (Exception e) { if (DEBUG) { Log.e(TAG, "Cannot get group timeline"); Log.e(TAG, Log.getStackTraceString(e)); } } return null; }
From source file:com.dm.material.dashboard.candybar.helpers.FileHelper.java
static boolean copyFile(@NonNull File file, @NonNull File target) { try {// w w w. ja v a 2s . c om if (!target.getParentFile().exists()) { if (!target.getParentFile().mkdirs()) return false; } InputStream inputStream = new FileInputStream(file); OutputStream outputStream = new FileOutputStream(target); byte[] buffer = new byte[1024]; int read; while ((read = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, read); } inputStream.close(); outputStream.flush(); outputStream.close(); return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); } return false; }
From source file:net.olejon.mdapp.LvhCategoriesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Transition overridePendingTransition(R.anim.slide_in_from_right, R.anim.slide_out_to_left); // Intent/* w ww. jav a 2 s .c o m*/ final Intent intent = getIntent(); final String categoryColor = intent.getStringExtra("color"); final String categoryIcon = intent.getStringExtra("icon"); final String categoryTitle = intent.getStringExtra("title"); JSONArray subcategories; try { subcategories = new JSONArray(intent.getStringExtra("subcategories")); } catch (Exception e) { subcategories = new JSONArray(); Log.e("LvhCategoriesActivity", Log.getStackTraceString(e)); } // Layout setContentView(R.layout.activity_lvh_categories); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.lvh_categories_toolbar); toolbar.setTitle(categoryTitle); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Recycler view RecyclerView recyclerView = (RecyclerView) findViewById(R.id.lvh_categories_cards); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(mContext)); if (mTools.isTablet()) { int spanCount = (subcategories.length() == 1) ? 1 : 2; recyclerView.setLayoutManager( new StaggeredGridLayoutManager(spanCount, StaggeredGridLayoutManager.VERTICAL)); } // Get categories recyclerView.setAdapter(new LvhCategoriesAdapter(mContext, subcategories, categoryColor, categoryIcon)); }
From source file:org.alfresco.mobile.android.application.extension.samsung.utils.SNoteUtils.java
public static Bitmap decodeFile(File f, int requiredSize, int dpiClassification) { InputStream fis = null;/*from w w w .ja v a 2s .c o m*/ Bitmap bmp = null; try { fis = new BufferedInputStream(new FileInputStream(f)); // decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(fis, null, o); fis.close(); // Find the correct scale value. It should be the power of 2. int scale = calculateInSampleSize(o, requiredSize, requiredSize); // decode with inSampleSize fis = new BufferedInputStream(new FileInputStream(f)); BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; o2.inPurgeable = true; o.inPreferredConfig = Bitmap.Config.ARGB_8888; o.inTargetDensity = dpiClassification; o.inJustDecodeBounds = false; o.inPurgeable = true; bmp = BitmapFactory.decodeStream(fis, null, o2); fis.close(); } catch (Exception e) { Log.w(TAG, Log.getStackTraceString(e)); } finally { IOUtils.closeStream(fis); } return bmp; }
From source file:org.alfresco.mobile.android.async.session.oauth.AccountOAuthHelper.java
public static void onNewOauthData(Context context, RetrieveOAuthDataEvent event) { AlfrescoAccount acc = SessionUtils.getAccount(context); AccountOAuthHelper.saveLastCloudLoadingTime(context); if (!event.hasException) { saveNewOauthData(context, acc, event.data); } else {/*from w w w .j a v a2 s . c o m*/ switch (acc.getTypeId()) { case AlfrescoAccount.TYPE_ALFRESCO_TEST_OAUTH: case AlfrescoAccount.TYPE_ALFRESCO_CLOUD: CloudExceptionUtils.handleCloudException(context, event.exception, true); break; default: break; } Log.e(TAG, Log.getStackTraceString(event.exception)); } }
From source file:info.papdt.blacklight.api.search.SearchApi.java
public static ArrayList<String> suggestAtUser(String q, int count) { WeiboParameters params = new WeiboParameters(); params.put("q", q); params.put("count", count); params.put("type", 0); params.put("range", 0); try {//from w w w . ja v a 2 s .co m JSONArray json = requestArray(Constants.SEARCH_SUGGESTIONS_AT_USERS, params, HTTP_GET); ArrayList<String> ret = new ArrayList<String>(); for (int i = 0; i < json.length(); i++) { ret.add(json.getJSONObject(i).optString("nickname")); } return ret; } catch (Exception e) { if (DEBUG) { Log.e(TAG, "Cannot search, " + e.getClass().getSimpleName()); Log.e(TAG, Log.getStackTraceString(e)); } return null; } }
From source file:com.example.android.common.logger.LogWrapper.java
/** * Prints data out to the console using Android's native log mechanism. * @param priority Log level of the data being logged. Verbose, Error, etc. * @param tag Tag for for the log data. Can be used to organize log statements. * @param msg The actual message to be logged. The actual message to be logged. * @param tr If an exception was thrown, this can be sent along for the logging facilities * to extract and print useful information. *///from w w w . j a v a 2s. c o m @Override public void println(int priority, String tag, String msg, Throwable tr) { // There actually are log methods that don't take a msg parameter. For now, // if that's the case, just convert null to the empty string and move on. String useMsg = msg; if (useMsg == null) { useMsg = ""; } // If an exeption was provided, convert that exception to a usable string and attach // it to the end of the msg method. if (tr != null) { msg += "\n" + Log.getStackTraceString(tr); } // This is functionally identical to Log.x(tag, useMsg); // For instance, if priority were Log.VERBOSE, this would be the same as Log.v(tag, useMsg) Log.println(priority, tag, useMsg); // If this isn't the last node in the chain, move things along. if (mNext != null) { mNext.println(priority, tag, msg, tr); } }
From source file:com.nagopy.android.xposed.SettingChangedReceiver.java
@Override public void onReceive(Context context, Intent intent) { Object obj = dataObject.get(); if (!StringUtils.equals(intent.getAction(), action) || obj == null) { context.unregisterReceiver(this); return;//from w w w. j a va2 s .com } Bundle extras = intent.getExtras(); if (extras == null || extras.size() != 2) { return; } try { // target?value???????? String target = extras.getString("target"); Object value = extras.get("value"); obj.getClass().getField(target).set(obj, value); onDataChanged(); } catch (Throwable t) { Logger.e(getClass().getSimpleName(), Log.getStackTraceString(t)); } }
From source file:org.proninyaroslav.libretorrent.core.IPFilterParser.java
private static String cleanupIPAddress(String ip) { if (ip == null) { return null; }//from w w w . jav a 2 s .co m String cleanupIp = null; try { InetAddress address = InetAddress.getByName(ip); cleanupIp = address.getHostAddress(); } catch (Exception e) { Log.e(TAG, "IP cleanup exception: " + Log.getStackTraceString(e)); } return cleanupIp; }