Try something like this:
package com.gabriloware.teslalib;
import java.io.PrintWriter;
import java.io.StringWriter;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
public class ExceptionHandler implements
Thread.UncaughtExceptionHandler {
private final Context myContext;
private final String LINE_SEPARATOR = "\n";
private Tesla MyTesla=null;
public ExceptionHandler(Context context) {
myContext = context;
}
public void uncaughtException(Thread thread, Throwable exception) {
StringWriter stackTrace = new StringWriter();
exception.printStackTrace(new PrintWriter(stackTrace));
StringBuilder errorReport = new StringBuilder();
errorReport.append("************ CAUSE OF ERROR ************\n\n");
errorReport.append(stackTrace.toString());
/*
errorReport.append("\n************ DEVICE INFORMATION ***********\n");
errorReport.append("Brand: ");
errorReport.append(Build.BRAND);
errorReport.append(LINE_SEPARATOR);
errorReport.append("Device: ");
errorReport.append(Build.DEVICE);
errorReport.append(LINE_SEPARATOR);
errorReport.append("Model: ");
errorReport.append(Build.MODEL);
errorReport.append(LINE_SEPARATOR);
errorReport.append("Id: ");
errorReport.append(Build.ID);
errorReport.append(LINE_SEPARATOR);
errorReport.append("Product: ");
errorReport.append(Build.PRODUCT);
errorReport.append(LINE_SEPARATOR);
errorReport.append("\n************ FIRMWARE ************\n");
errorReport.append("SDK: ");
errorReport.append(Build.VERSION.SDK);
errorReport.append(LINE_SEPARATOR);
errorReport.append("Release: ");
errorReport.append(Build.VERSION.RELEASE);
errorReport.append(LINE_SEPARATOR);
errorReport.append("Incremental: ");
errorReport.append(Build.VERSION.INCREMENTAL);
errorReport.append(LINE_SEPARATOR);
*/
if (MyTesla==null)
MyTesla = new Tesla(myContext);
MyTesla.LogEvent("EXCEPTION",errorReport.toString());
Intent intent = new Intent(myContext, CrashActivity.class);
intent.putExtra("error", errorReport.toString());
myContext.startActivity(intent);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(10);
}
}
public class TeslaApplication extends Application {
public LogFragment Logger=null;
@Override
public void onCreate() {
super.onCreate();
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
new Tesla(this).Init2();
}
...
On Tue, Nov 8, 2016 at 12:01 PM, Chairi Kiourt <[email protected]> wrote:
> Hi everyone,
>
> I am new on developing android app and i have a problem.
>
> I have developed and app for restaurant order in android studio, which
> communicates wit an Apache server to get the dishes, dish categories,
> available tables, receipts and etc.
> I use php to get the data from the mysql and to store data from the tablet
> (Android 5, Lenovo TAB 3 710F 7" ESSENTIAL).
> For me everything worked ok, in the emulator as well as in the tabet.
>
> I gave this app to an restaurant and they tell me that the app crashes
> some time, without giving any error notification, it say just that the app
> crashed and will restart.
> All the system works offline, without internet, just a local network.
>
> Now he question is, is there any way to keep somehow crash report in the
> tablet and in the end after some day to get them ?????
> I find out that in logcat i can get the crash report if i get it exactly
> after the crash, the problem is that i cannot be there to get the logcat
> file in that moment.
>
> Please any help
>
>
> Thank you in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/android-developers/1764d4ab-7c54-48d8-95a3-
> 40faab692b12%40googlegroups.com
> <https://groups.google.com/d/msgid/android-developers/1764d4ab-7c54-48d8-95a3-40faab692b12%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/CABfabRgJd20QJiG%3DpdEvq%2BF3vvihk4xaF6NyPBiQtGNynWFO9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.