Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to log all Activity methods calls?

I would like to have a quick way to be able to log all the calls to all the super methods called by the activity.

I have tried this https://github.com/stephanenicolas/loglifecycle

but for some reason it does not work with AppCompatActivity...

I could ask my IDE to override all the methods; but how to add Log to all of them? Manually? There must be a way..

like image 585
Lisa Anne Avatar asked Apr 30 '15 16:04

Lisa Anne


People also ask

Does Android have a system log?

Overview. The Android system has a logging facility that allows system-wide logging of information, from applications and system components. This is separate from the Linux kernel's own logging system, which is accessed using 'dmesg' or '/proc/kmsg'. However, the logging system does store messages in kernel buffers.

How do I find system logs on Android?

Android allows collecting system logs using Logcat. Log messages can be viewed in a Logcat window in Android Studio, or you can use the command line tool to pull them. Several Android apps are also available in the Google Play store that allow easy access to these tools.

What is the difference between onStop and onDestroy?

Once onStop() is called then onRestart() can be called. onDestroy() is last in the order after onStop(). onDestory() is called just before an activity is destroyed and after that it is gone it is not possible to resurrect this.

What is onStop Android?

onStop() Method In Android Activity Life Cycle After a millisecond of that method next onStop() method will execute. Means here also Activity is not visible to user when onStop() executed. We will use onStop() method to stop Api calls etc. This onStop() method will. clean up all your activities resources.


1 Answers

You could go around and play yourself with stacktrace

StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();

From the docs:

The last element of the array represents the bottom of the stack, which is the least recent method invocation in the sequence.

EDIT: There seems to be a whole post about this HERE

like image 196
Bojan Kseneman Avatar answered Oct 05 '22 23:10

Bojan Kseneman