Android Open Source - AndroIUT Andro I U T Logger






From Project

Back to project page AndroIUT.

License

The source code is released under:

GNU General Public License

If you think the Android project AndroIUT 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.iutdijon.androiut2.util;
//from w  w  w  .  j a  v a2  s.c om
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;

import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicNameValuePair;

import android.content.Context;
import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
import android.os.Build;
import android.text.format.DateFormat;

import com.iutdijon.androiut2.global.AndroIUTApplication;
import com.iutdijon.androiut2.util.loaders.AndroIUTHTTPConnection;


public class AndroIUTLogger implements Thread.UncaughtExceptionHandler {

  private static Writer string_writer;
  private static PrintWriter print_writer;
  private static Thread.UncaughtExceptionHandler super_handler;
  
  private final Context application_context;
  
  public AndroIUTLogger(Context c) {
    application_context = c;
    string_writer = new StringWriter();
    print_writer = new PrintWriter(string_writer);
    
    super_handler = Thread.getDefaultUncaughtExceptionHandler();
    
    Thread.setDefaultUncaughtExceptionHandler(this);
  }

  @Override
  public void uncaughtException(final Thread t, final Throwable e) {
    e.printStackTrace();
    new AsyncTask<Void, Void, Void>() {
      
      @Override
      protected Void doInBackground(Void... params) {
        try{
          e.printStackTrace(print_writer);
          String message = string_writer.toString();
          String user = AndroIUTApplication.getInstance().getAccount() != null ? AndroIUTApplication.getInstance().getAccount().getMail() : "unknow"; 
          
          AndroidHttpClient client = AndroIUTHTTPConnection.getHTTPClient();
  
          HttpPost post_request = new HttpPost("http://iutdijon.u-bourgogne.fr/pedago/iq/projandroid/webapi.php");
  
          ArrayList<NameValuePair> log_params = new ArrayList<NameValuePair>();
          log_params.add(new BasicNameValuePair("function", "logging"));
          log_params.add(new BasicNameValuePair("client", user));
          log_params.add(new BasicNameValuePair("error_message", message));
          log_params.add(new BasicNameValuePair("error_date", DateFormat.format("dd-MM-yyyy", Calendar.getInstance(Locale.FRANCE)).toString()));
          log_params.add(new BasicNameValuePair("os_version", Build.VERSION.RELEASE));
          log_params.add(new BasicNameValuePair("app_version", application_context.getPackageManager().getPackageInfo(application_context.getPackageName(), 0).versionName));
  
          post_request.setEntity(new UrlEncodedFormEntity(log_params));
          client.execute(post_request);
          client.close();
          
        }catch(Exception ex){
          ex.printStackTrace();
        }finally{
          super_handler.uncaughtException(t, e);
        }
        
        return null;
      }      
    }.execute();
  }

}




Java Source Code List

.ADEResourcesDataTree.java
com.iutdijon.androiut2.ade.activities.ADEActivity.java
com.iutdijon.androiut2.ade.activities.ADEListResourcesChooser.java
com.iutdijon.androiut2.ade.activities.OnImageDownloadedCallback.java
com.iutdijon.androiut2.ade.service.ADEICalendarDownloader.java
com.iutdijon.androiut2.ftp.activities.FTPActivity.java
com.iutdijon.androiut2.ftp.adapters.FTPFileListAdapter.java
com.iutdijon.androiut2.ftp.data.FTPCommandResult.java
com.iutdijon.androiut2.ftp.data.FTPCommandWrapper.java
com.iutdijon.androiut2.ftp.data.FTPCommand.java
com.iutdijon.androiut2.ftp.services.FTPDownloadMonitor.java
com.iutdijon.androiut2.ftp.services.FTPServiceCall.java
com.iutdijon.androiut2.ftp.services.ProgressDownload.java
com.iutdijon.androiut2.global.AndroIUTApplication.java
com.iutdijon.androiut2.iut.activities.HomeActivity.java
com.iutdijon.androiut2.iut.activities.LoginActivity.java
com.iutdijon.androiut2.iut.data.Credential.java
com.iutdijon.androiut2.iut.data.UserFactory.java
com.iutdijon.androiut2.iut.data.account.StudentAccount.java
com.iutdijon.androiut2.iut.data.account.TeacherAccount.java
com.iutdijon.androiut2.iut.data.account.UserAccount.java
com.iutdijon.androiut2.iut.services.IUTLoginServiceCall.java
com.iutdijon.androiut2.mail.activities.MailActivity.java
com.iutdijon.androiut2.mail.activities.MailReaderActivity.java
com.iutdijon.androiut2.mail.adapters.MailDisplayAdapter.java
com.iutdijon.androiut2.mail.adapters.MailsListAdapter.java
com.iutdijon.androiut2.mail.services.EmailUtils.java
com.iutdijon.androiut2.mail.services.MailReader.java
com.iutdijon.androiut2.mail.services.MailService.java
com.iutdijon.androiut2.schooling.activities.SchoolingActivity.java
com.iutdijon.androiut2.schooling.activities.SchoolingTabActivity.java
com.iutdijon.androiut2.schooling.adapters.SectionedAdapter.java
com.iutdijon.androiut2.schooling.data.Absence.java
com.iutdijon.androiut2.schooling.data.Mark.java
com.iutdijon.androiut2.schooling.data.SchoolingData.java
com.iutdijon.androiut2.schooling.service.SchoolingDataServiceCall.java
com.iutdijon.androiut2.util.AndroIUTLogger.java
com.iutdijon.androiut2.util.IOUtils.java
com.iutdijon.androiut2.util.PreferencesManager.java
com.iutdijon.androiut2.util.UIUtil.java
com.iutdijon.androiut2.util.adapters.AbsencesAdapter.java
com.iutdijon.androiut2.util.adapters.BitmapAdapter.java
com.iutdijon.androiut2.util.adapters.CalendarAdapter.java
com.iutdijon.androiut2.util.adapters.IAdapter.java
com.iutdijon.androiut2.util.adapters.MarksAdapter.java
com.iutdijon.androiut2.util.adapters.UserAdapter.java
com.iutdijon.androiut2.util.adapters.XmlAdapter.java
com.iutdijon.androiut2.util.bridge.BridgeFinder.java
com.iutdijon.androiut2.util.loaders.AndroIUTHTTPConnection.java
com.iutdijon.androiut2.util.loaders.AsyncServiceCall.java
com.iutdijon.androiut2.util.loaders.BitmapDownloaderTask.java
com.iutdijon.androiut2.util.loaders.GetAsyncServiceCall.java
com.iutdijon.androiut2.util.loaders.ImageDownloader.java
com.iutdijon.androiut2.util.loaders.PostAsyncServiceCall.java
com.iutdijon.androiut2.util.observers.Observable.java
com.iutdijon.androiut2.util.observers.Observer.java
com.iutdijon.androiut2.util.security.SecureCenter.java
com.iutdijon.androiut2.util.view.ImageZoomView.java
com.iutdijon.androiut2.util.zoom.AspectQuotient.java
com.iutdijon.androiut2.util.zoom.DynamicZoomControl.java
com.iutdijon.androiut2.util.zoom.LongPressZoomListener.java
com.iutdijon.androiut2.util.zoom.PinchZoomListener.java
com.iutdijon.androiut2.util.zoom.SimpleZoomListener.java
com.iutdijon.androiut2.util.zoom.ZoomState.java
com.iutdijon.androiut2.util.zoom.util.Dynamics.java
com.iutdijon.androiut2.util.zoom.util.SpringDynamics.java