Android Studio: Logcat search vs. filter - android

I have a lot of output in my logcat (Android Monitor) which in which I would like to find a specific part. This part starts with a keyword, which is followed by several logs with information I want to check.
I know there is the possibilty to filter the logcat by the Log level and searching for expressions. When I type the keyword in the UI only the logs are filtered by the keyword.
I am interessted in the lines/logs which are followed by the keyword. Is there a search option, where no information is filtered and the results are shown in the complete log?
Commands proposed in this answer like Ctrl+s do not work.

a while ago I had the same problem and created a Logger helper class which help me by tagging the android logs automatically with the line_number, ClassName and Method name via reflection, this had helped me a lot, for example when I just want to filter the output of a method I write the name of the method in the logcat filter and it just gives me all logs inside that method, same with line numbers and Classes, try it out I have made a gist with it.
To use it is easy just do Logger.getLogger and assign to some easy name like log then log like normally just log.d("string") without the tag and it automatically takes the line method and class, It has good documentation on it so you might be able to tweak it if you want, hope it helps.

Related

Search for used and unused functions

Assumptions
I have an application with a very large number of screens.
I see the application for the first time so I don't know it
I have a method that connects to the Web Service and I don't know if it is actually used.
Is there any way to check (without running the application) whether the method is actually used in the application?
In Android Studio, you can easily find if a method is used or not.
Right click on the method > "Find usage"
Put a breakpoint on method and start debugging to know whether control
transfers to that method.
Put Log statements inside method to know whether they are executed.
Not recommended: Use Toast messages.
If I understand you, you're looking for "dead code", right ?
You can use Android Lint then: Analyze > Inspect Code...
In the results, Java part I think, you will find Declaration redundancy which will point you the dead code of the project (or the analyzed package)

Appcelerator Hyperloop Android handle return data

I am trying to use Hyperloop to wrap the Estimote SDK. I've made some significant progress and have been able to range for and find beacons.
My problem is with the data returned from the Estimote SDK. The onBeaconsDiscovered event returns all the beacons found in a List (java.util.List) and I can't seem to do anything with it. Trying to call a method on the list results in 'not a function errors' ie: beaconsRanged.size() gives me beaconsRanged.size is not a function.
I also tried to print the object to the console, but that gave me 'maximum call stack exceeded' errors.
What is the proper way to handle this type of return data?
There is currently an open ticket about Lists in Hyperloop: https://jira.appcelerator.org/browse/TIMOB-24684
That might block this from working

Where do i see what queries have been executed

How do i see a log of all the queries that have been executed in my app? im using classic eclipse. in the logcat i cant see any queries that have occurred while my app has been running.
Where do i see this? ive looked at the log and i do not see any queries or anything in there...
Any help would be greatly appreciated.
Queries are not logged automatically. You will need to manually log them with calls to Log.d() etc.
I'm not sure if there is a way to see queries performed by your application automatically, but it would probably be a good idea to use the Log class and write debug log entries when you perform a query, so that they get registered there, with a tag defined by you which you can use to easily filter these messages in the log cat console.

Android Edit Call Log

I was wondering if there was a way to modify the call log? I would like to edit date on the call.
If for example I received a call today I would like to edit the log and change the date to yesterday.
Anyone have any ideas?
That seems like a really weird thing to do, but...
The provider for call log data (CallLog.Calls) only publicly documents methods to query the data, not modify it. You could go into the Android source to see if there is an undocumented method.

How do I create debug viewer for an Android Application?

I need a starting point to make the following possible.
I have a Main activity start when the Android application starts, as well as an alternate screen that I want to be Debug output (only strings). What I am struggling with is, what layout do I use for the debug screen, and how do I keep this screen constantly populating while I am viewing my Main activity? I do not have any code for this functionality as everything I have tried has crashed my application, so I was hoping to start fresh. I am a super noob to Android so any information would be helpful.
Thanks in advance.
EDIT:
I am sorry, I should have been more specific. I will be receiving Debug information over Bluetooth from a robot. Sensor information, location, possibly a camera feed, etc. At the moment I am looking for a good way to display the Debug information that is Text only. I have a Main Activity that will have the controls of the Robot, and I want to have a second separate screen (that can be switched to from the Options menu) that will have the debug information updated in real time. Don't worry about any of the Bluetooth stuff I can already read and write to the socket. Just the "debug screen"
I would suggest using the log associated with each method, listener, etc. you'd like to keep track of. See here: http://developer.android.com/reference/android/util/Log.html
The TAG identifies the aspect you'd like to track in your logCat:
private static final String TAG = "MyActivity";
Then you simply add the following into your methods, listeners, etc.
Log.v(TAG, insert variables and other info here);
You use your app on the device or emulator normally and filter your logCat output for the items your tracking. You can do it simultaneously or inspect you logcat after you've used the app for a bit.
Hope that helps...
I would use the eclipse debugger. The console output as well as logcat are also very useful for debugging.
If you must create your own debug screen I would create an asynctask that can run in the background. Each time you get output that should go to your debugger I would send it to your asynctask and have the asynctask store it in the database along with a time stamp. Then any time you want to view debug output pull up your custom view that pulls data from your database. You could use a LinearLayout that has 6 textviews. The textviews could display the last 6 messages from your debugger. How you implement the layout is really up to you. Just make sure you persist the debug info in your database rather than in memory or I can almost guarantee some of your debug info will be lost.
After doing some more research I have decided to use a TabActivity instead of trying to do two separate screens. This allows the Tabs to be under 1 Activity and I do not need to worry about inter-Activity communication. Thank you all for you help.

Categories

Resources