Hello MfA devs,
I have a routine just like I use in MonoTouch (and works) that writes info
such as exception to a log file.
private static void WriteToLog(string msg)
{
#if DEBUG
Android.Util.Log.Info("LOGBOOK PRO", msg);
#endif
using (System.IO.StreamWriter s =
System.IO.File.AppendText(Utils.LogFilename))
{
s.WriteLine();
s.WriteLine(msg);
s.WriteLine("--------------------------------------------");
s.WriteLine();
}
}
}
I am writing to:
public readonly static string BaseDir =
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
public readonly static string LogFilename = System.IO.Path.Combine(BaseDir,
"log.txt");
And when a user submits a bug report (via e-mail) from the about area of the
app I attach the file using the code as follows, but for whatever reason, I
never get log files, either they are not being created OR attached, not sure
which just yet.
private void SendBugReport()
{
var recips = new string[] { "[email protected]" };
var intent = new Intent(Intent.ActionSend);
intent
.PutExtra(Intent.ExtraEmail, recips)
.PutExtra(Intent.ExtraSubject, "Android App Bug Report")
.PutExtra(Intent.ExtraText,
String.Format("{0}\n\nSettings\n{1}\nDevice ID: {2}", MessageBody,
App.Settings.ToString(),App.UDID))
.SetType("application/octet-stream");
if (File.Exists(Utils.LogFilename))
{
Java.IO.File file = new Java.IO.File(Utils.LogFilename);
intent.PutExtra(Intent.ExtraStream,
Android.Net.Uri.FromFile(file));
}
try
{
StartActivity(Intent.CreateChooser(intent, "Send E-mail
Using..."));
}
catch (Exception ex)
{
Logger.LogException(ex.Message, ex, "ContactUs");
Toast.MakeText(this, "There are no e-mail clients
installed.", ToastLength.Short).Show();
}
}
Anyone see anything wrong with what I'm doing? The intention is to write a
log file to track exceptions and messages and then attach that file to the
e-mail. If I can attach a second file I'd love to also send the database
(SQLite) but I'm not sure if I can attach multiple attachments or not, or
don't know how to.
Thank you!
Neal Culiner
NC Software, Inc.
<http://www.nc-software.com/> http://www.nc-software.com/
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid