Android Open Source - QLog-Android Q Log Demo Activity






From Project

Back to project page QLog-Android.

License

The source code is released under:

Copyright (c) 2011 QBurst, http://qburst.com/ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redi...

If you think the Android project QLog-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qburst.demo;
//  www . ja  v  a2s  .c  om
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

//import loggers
import com.qburst.logger.*;

public class QLogDemoActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        
      /* Setup logging for the application */
      QLog.setupLogging(getApplication());
      
      super.onCreate(savedInstanceState);
        
        
        setContentView(R.layout.main);
        
        final Button btnRegularLog = (Button) findViewById(R.id.btnRegularLog);
        final Button btnCrashLog = (Button) findViewById(R.id.btnCrashLog);
        final EditText edittext = (EditText) findViewById(R.id.txtRegularLogText);
        
        btnRegularLog.setOnClickListener(new View.OnClickListener() {      
      public void onClick(View v){
        
        Toast toast = Toast.makeText(getApplicationContext(),
            "Logging " + edittext.getText() + "....", 1000);
        toast.show();
        /*
         * This will show up in Android system log (check Logcat view)
         * as well as send a message to the QLog server at Qburst.
         */
        QLog.d("DEMOAPP", edittext.getText().toString()); 
        
      }
    });
        
        btnCrashLog.setOnClickListener(new View.OnClickListener() {
      
      public void onClick(View v) {

        /* Try and generate a crash
         * findViewById(13323) will not resolve to any allocated instance of an EditText
         * Any usage of the handle crashEdit to access instance members will cause a crash
         */
        EditText crashEdit= (EditText) findViewById(13323); 

        Toast toast = Toast.makeText(getApplicationContext(),
            "Logging " + crashEdit.getText() + "....", 1000);
        toast.show();
        
      }
    });
        
    }
}




Java Source Code List

com.qburst.demo.QLogDemoActivity.java
com.qburst.logger.QLog.java