I didn't include the LogEvent implementation on purpose, once you have the
string you can do whatever you like with it, perhaps keep an ErrorLog table
in your database?

On Nov 8, 2016 1:32 PM, "Chairi Kiourt" <chai...@gmail.com> wrote:
>
> Thank you for your answer Steve Gabrilowitz, like i notice this code
creates a string with the error, but i didnt understand if stores the
string into a file, if it stores the error into a file, where i can find
the file ??? and does any error is stored into a new file ??? which means
that i will have several error files for several crashes ???
>
>
> Thank you again
>
>
>
> On Tuesday, November 8, 2016 at 7:53:04 PM UTC+2, Steve Gabrilowitz wrote:
>>
>> 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 <cha...@gmail.com> 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 android-developers+unsubscr...@googlegroups.com.
>>> To post to this group, send email to android-d...@googlegroups.com.
>>>
>>> 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
.
>>> 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 android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> 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/2e53025f-df5e-45fd-9bc2-465c1788c894%40googlegroups.com
.
>
> 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 android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
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/CABfabRhf9N2FWEipoBf8jiUQWmCF%3D91cSB81vgEmc-MwEvKa3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to