Reading logs programatically
Writing logs into logcat from yuor application is quite easy, reading the logcat programmatically is just a bit more tricky.
Reading logs is usually used for bugreport purposes.
The following code reads logs and displays then in a TextView:
- public class LogTest extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- try {
- StringBuilder log=new StringBuilder();
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- log.append(line);
- }
- TextView tv = (TextView)findViewById(R.id.textView1);
- tv.setText(log.toString());
- }
- }
- }
When I first fint this solution, I was afraid that it will require some extreme permission because it runs logcat like a console command.
Fortunatelly there is a permission for reading logs:
- <uses-permission android:name="android.permission.READ_
LOGS" />
You can add any more parameters to the logcat command string, just like it is defined in the documentation.
When implementing a bugreport feature, with sending logs to yuorself, dont forget that many applications outputs personal information into the logcat, so a policy about them is definetly needed.
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@Idevicegazette (iDevice Gazette)
GSM-to-Skype bridge lets you lose those roaming fees http://bit.ly/lbRJeh #android
11 years 45 weeks ago -
@tommy_banane (tom b.)
RT @AndroidFavorite: #Android New Desktop Android Market Is Live, Adds Several New Features http://zorr0.nl/lFwXNz
11 years 45 weeks ago -
@dwilliams5 (Dennis Williams)
just completed a runtastic run of 3.02 km in 40 min 11 s with #runtastic #Android App: http://tinyurl.com/5tvrpe3
11 years 45 weeks ago -
@S_Pinz (Spinz!)
RT @Androidheadline: Out of box #LG Optimus 3D got Quadrant 2420 score. Thanks @blink_c #io2011 #android http://twitpic.com/4whkdz
11 years 45 weeks ago -
@tayaitapps (Taya IT)
Next Google TV Looks A Lot Like Android http://t.co/dvlTim3 via @alleyinsider #google #apple #android #tv #honeycomb
11 years 45 weeks ago
Poll
Useful resources
Android Development Projects
- iOS/Android Developer to take older Games and bring them Current
- Android apps developer - need to finish urgent.
- Buliding MobileApp For onlie order
- looking for android APP developers
- Create an ecommerce app
- text-to voice for smartphones IOS - GOOGLE - HARMONY - AND ALEXA
- Optimize Images on App
- Create small feature with drag-drop text for Android
- Scouting for advanced website and Mobile apps developers. Potential Long-term contract.
- BLACK SCREEN