[Galaxy Ace S5830 Android Development] evil_penguin:
How To Get A Logcat

​

Well I always read on the forum about logcat, I knew it was about getting logs or system activity, thought it was a very difficult thing to do and then I read about it and realized it is so simple.In the below explanation

I will show you an app which is running even when it should not and hence draining the battery.So, here we go.

What is logcat?

Logcat is the command to view the internal logs of the Andr

oid system. Viewing logs is often the best way to diagnose a problem, and is required for many issues. This way you'll find out what apps are doing in the background without you noticing.

Advantages of Logcat-

*Debugging

*You can see what processes are running, if a process is running after a certain interval of time, it will eat battery. So you can also find out what is draining your battery.

Etc.....:p

How do I install it?

1.Make sure you've enabled on USB debugging on your phone in Settings->Application ->Development

2. Get the Android SDK here:--http://developer.android.com/sdk/index.html

3.Extract the SDK to any folder say C:\Android

4.Make sure that you have installed the drivers for your phone and the operating system recognizes your phone.

Everything installed? Continuing...

Now how to actually access the log, everything in*italic*are commands you need to enter.

1-Open the 'run' dialog by pressing the 'Windows' + 'r' buttons on your keyboard (minimize the browser & other non-windows programs)

2-cmd*(this will open a DOS prompt)

3-cd c:\Android\tools*(go to the directory where you extracted the SDK)

4-adb shell

5-Now you'll see just a '$'logcat

You can now just press the power button on your phone to see what happens. It displays everything the device is doing.

So the thing is: leave your device connected for a while and see what is actually going on when you're not using it.

An Example

>Twidroid auto refreshing my Tweets

D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 92ms D/dalvikvm( 2216): GC freed 6646 objects / 313032 bytes in 104ms D/NetworkLocationProvider( 75): onCellLocationChanged [***] D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 D/dalvikvm( 1253): GC freed 281 objects / 12688 bytes in 93ms D/NetworkLocationProvider( 75): onCellLocationChanged [***] D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 D/dalvikvm( 75): GC freed 41839 objects / 1963448 bytes in 88ms D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 94ms D/NetworkLocationProvider( 75): onCellLocationChanged [***] D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 D/dalvikvm( 2216): GC freed 6657 objects / 314648 bytes in 35ms D/NetworkLocationProvider( 75): onCellLocationChanged [***] D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 D/dalvikvm( 1253): GC freed 279 objects / 12640 bytes in 94ms D/NetworkLocationProvider( 75): onCellLocationChanged [***] D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8 D/dalvikvm( 1287): GC freed 3 objects / 72 bytes in 60ms D/dalvikvm( 2216): GC freed 6661 objects / 314192 bytes in 104ms D/NetworkLocationProvider( 75): onCellLocationChanged [***] D/LocationManager( 2216): removeUpdates: listener = com.levelup.beautifulwidgets .UpdateWeather$2@447843d8

If you're seeing apps that are constantly busy when they shouldn't that means they're draining battery because of bugs in the app/ bad coding/ ...

There are vaious examples. In this i took an example of battery drain.

Hope it helps you.