Showing posts with label #tip. Show all posts
Showing posts with label #tip. Show all posts

Wednesday, December 19, 2012

Filter logcat Output by Tag Names

When debugging on android development, sometimes it is hard to find what we need when there are too much data displays on logcat. Most of the time when I do debugging on android, I use the terminal. It's pretty fast and I find it more comfortable than the logcat from Eclipse android plugin. Sometimes I missed out important data because there are unnecessary information displayed on logcat. So what I do is to save the logcat into a file and check it into a browser. This is time consuming though you have all the information. One way to sort out this problem is to filter logcat. adb logcat command has the option to filter your tags that you define in your application. In your code, you might have something similar like this:
private static final String TAG = "Fragment01";
Log.d(TAG, "getUserVisibleHint=" + getUserVisibleHint());
To display "Fragment01" in logcat,
$ adb logcat -s "Fragment01"
But this information isn't enough. What if you also need to see the values of fragment 2? or fragment 3? and etc.? Run this command.
$ adb logcat -s "Fragment01" "Fragment02" "Fragment03"
By adding the tag names on the command this will allow adb to filter it and display in logcat. Do you have some ideas similar to this? Glad if you could share. Let me know your thoughts.

Friday, August 10, 2012

Multiple Workspaces in Eclipse

If you're on the point where all your projects are flooded on your Eclipse package explorer, chances are very difficult to find other library projects when working on a project that references those projects. One way to organize your Eclipse projects is to switch workspaces.  To switch workspaces, go to Eclipse > File > Switch Workspace.

This is a great solution but you will loose all your settings.  Settings like keybindings, code formats, and custom templates are gone.  To set the settings to your new workspace, just copy the folder from your old workspace to your new workspace.

$ cp {old_workspace}/.metadata/.plugins/.org.eclipse.core.runtime/.settings {new_workspace}/

Restart Eclipse.