Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
evil_penguin
Old
(Last edited by evil_penguin; 17th April 2012 at 01:46 PM.)
#1  
evil_penguin's Avatar
Recognized Contributor - OP
Thanks Meter 682
Posts: 1,618
Join Date: Oct 2011
Post [Tutorial] How to get a Logcat -example - check for Battery drain

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.....

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

Code:
 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.

I do NOT answer technical questions via PM. Post it in a thread.
Current Devices ->>
Samsung Galaxy Nexus
-Best device i've used
Samsung Galaxy Tab 7.7 GT-P6800
-My first tablet,Awesome battery life
Old devices :
Samsung Galaxy Ace S5830{SOLD}
-My first Android phone!
The Following 15 Users Say Thank You to evil_penguin For This Useful Post: [ Click to Expand ]
 
chase_me
Old
#2  
Member
Thanks Meter 0
Posts: 61
Join Date: Mar 2012
Nice xplanation mate
+1
 
-RDR-
Old
#3  
Senior Member
Thanks Meter 271
Posts: 1,801
Join Date: Dec 2011
Location: somewhere in XDA
Great tutorial will try it thanks a lot




You know you are rooted when you use XDA more than FB
Currently using one beast of a rom


 
Prawesome
Old
#4  
Prawesome's Avatar
Senior Member
Thanks Meter 1596
Posts: 7,895
Join Date: Sep 2011
Location: Error 404- Not found
Or,you could just download CatLog from the market and use it to view the log
"Thanks button is just to avoid "thanks" posts in threads. Nothing more than that. Don't ask in signature or post for it and defeat the purpose why it was introduced"
 
evil_penguin
Old
#5  
evil_penguin's Avatar
Recognized Contributor - OP
Thanks Meter 682
Posts: 1,618
Join Date: Oct 2011
Quote:
Originally Posted by Prawesome View Post
Or,you could just download CatLog from the market and use it to view the log
Ya that's easy

I do NOT answer technical questions via PM. Post it in a thread.
Current Devices ->>
Samsung Galaxy Nexus
-Best device i've used
Samsung Galaxy Tab 7.7 GT-P6800
-My first tablet,Awesome battery life
Old devices :
Samsung Galaxy Ace S5830{SOLD}
-My first Android phone!
 
Evil_Genius2496
Old
#6  
Evil_Genius2496's Avatar
Senior Member
Thanks Meter 31
Posts: 138
Join Date: Nov 2011
Location: Mumbai
Or you can always do logcat>sdcard/logcat.txt from a terminal emulator!
XDA FEVER!!!
The Following 2 Users Say Thank You to Evil_Genius2496 For This Useful Post: [ Click to Expand ]
 
LewisGauss
Old
#7  
LewisGauss's Avatar
Recognized Contributor
Thanks Meter 610
Posts: 3,085
Join Date: Sep 2011
Location: Mars, Via Lactea
Awesome tutorial man.

Sent from my GT-S5830 using xda premium
Post composed by Lewis
Current Device : Samsung Galaxy Ace
ROM : CyanogenMod 10.1
Lewis' Twitter | Google+
 
evil_penguin
Old
#8  
evil_penguin's Avatar
Recognized Contributor - OP
Thanks Meter 682
Posts: 1,618
Join Date: Oct 2011
Quote:
Originally Posted by yeowwwai View Post
Awesome tutorial man.

Sent from my GT-S5830 using xda premium
Thanks

I do NOT answer technical questions via PM. Post it in a thread.
Current Devices ->>
Samsung Galaxy Nexus
-Best device i've used
Samsung Galaxy Tab 7.7 GT-P6800
-My first tablet,Awesome battery life
Old devices :
Samsung Galaxy Ace S5830{SOLD}
-My first Android phone!
 
R4Ck
Old
#9  
Senior Member
Thanks Meter 16
Posts: 122
Join Date: Aug 2011
Location: Brasília
Yeah, now i'm gonna discover what is causing the unmounts of my sd
 
SuperDev
Old
#10  
Member
Thanks Meter 4
Posts: 56
Join Date: Feb 2012
Atlast the recognized contributor:thumbdown: contributed something!

Sent from my GT-I9100 using xda premium

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Flash Custom ROM and Recovery to Samsung Galaxy S 4

After reading about Dan Rosenberg’s bootloader exploit for the Samsung Galaxy S 4,I … more

Windows-Based Multi-Tool for the Sony Xperia U

If you are a flashaholic and an owner of the Sony Xperia U, you may be interested in the … more

XDA University: Crafting Recovery-Flashable Packages

Those of us who use Linux on a day to day basis don’t think twice about sinking … more