+package ai.suanzi.rtmpclient;
+
+import android.content.Intent;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import de.mindpipe.android.logging.log4j.LogConfigurator;
+import java.util.Properties;
+import javax.mail.Transport;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.InternetAddress;
+import java.util.Date;
+import android.os.StrictMode;
+
+import java.io.File;
+
+public class LogUtil {
+
+ private static Logger gLogger;
+ private static final String FILE_NAME = "log.txt";
+ private static final long MAX_SIZE = 1024 * 1024 * 10; // 10M
+ private static String logFile = "";
+
+
+ public static void config(File dir) {
+ try {
+ final LogConfigurator logConfigurator = new LogConfigurator();
+ //String fname = getExternalFilesDir(null) + File.separator + "log.txt";
+ logFile = dir + File.separator + FILE_NAME;
+ logConfigurator.setFileName(logFile);
+ logConfigurator.setRootLevel(Level.DEBUG);
+ logConfigurator.setLevel("org.apache", Level.ERROR);
+ logConfigurator.setMaxFileSize(MAX_SIZE);
+ logConfigurator.configure();
+ gLogger = Logger.getLogger("LogUtil");
+ gLogger.error("#######################################");
+ gLogger.debug("Log file is located at: " + logFile);
+
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ try {
+
+
+ int SDK_INT = android.os.Build.VERSION.SDK_INT;
+ if (SDK_INT > 8)
+ {
+ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
+ .permitAll().build();
+ StrictMode.setThreadPolicy(policy);
+ //your codes here
+ MailUtil.sendMail();
+
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+
+
+}
+
+
+//
+//
+// public void sendEmail()
+// {
+//
+// private static final int PICK_FROM_GALLERY = 101;
+// int columnIndex;
+// try
+// {
+//
+//
+//
+// final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
+// emailIntent.setType("plain/text");
+// emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "Email" });
+// emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
+// if (URI != null) {
+// emailIntent.putExtra(Intent.EXTRA_STREAM, URI);
+// }
+// emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is a message");
+// this.startActivity(Intent.createChooser(emailIntent,"Sending email..."));
+// }
+// catch (Throwable t)
+// {
+// Toast.makeText(this, "Request failed try again: " + t.toString(),Toast.LENGTH_LONG).show();
+// }
+// }
+// public void openFolder()
+// {
+// Intent intent = new Intent();
+// intent.setType("image/*");
+// intent.setAction(Intent.ACTION_GET_CONTENT);
+// intent.putExtra("return-data", true);
+// startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_GALLERY);
+// }
+//
+// public static sendLogs(){
+//
+// }
+//
+// public void SendLoagcatMail(){
+//
+// // save logcat in file
+// /*File outputFile = new File(Environment.getExternalStorageDirectory(),
+// "logcat.txt");
+// try {
+// Runtime.getRuntime().exec(
+// "logcat -f " + outputFile.getAbsolutePath());
+// } catch (IOException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }*/
+// String fname = getExternalFilesDir(null) + File.separator + "log.txt";
+//
+// File logfile = new File(fname);
+//
+// //send file using email
+// Intent emailIntent = new Intent(Intent.ACTION_SEND);
+// emailIntent.setType("vnd.android.cursor.dir/email");
+// String to[] = {"seudut@gmail.com"};
+// emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
+// // the attachment
+// emailIntent.putExtra(Intent.EXTRA_STREAM, logfile.getAbsolutePath());
+// // the mail subject
+// emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
+// startActivity(Intent.createChooser(emailIntent , "Send email..."));
+// }
+
+//}