How to send crash reports to developer?

佐手、 提交于 2019-12-03 06:23:26

The ACRA library will fulfill your requirement. You just need to setup the email. The tutorial and setup is defined here.

Download the library with .jar in lib

You just need to define the Application class and write the following code just above application class and override onCreate() method like this

     @ReportsCrashes(formKey = "", // will not be used
                    mailTo = "reports@yourdomain.com",
                    mode = ReportingInteractionMode.TOAST,
                    resToastText = R.string.crash_toast_text)
    public class MyApplication extends Application {

 @Override
    public void onCreate() {
        ACRA.init(this);
        super.onCreate();
    }

}

Thats it. The email action will get opened whose body contains crash report.

You can Use ready APi Such as BugSence and crittercism

After implementation SDK you will recive crush report with crush logs to your email if you whant

For BugSance Download SDK

import com.bugsense.trace.BugSenseHandler;

Make sure you also add the line

 <uses-permission android:name="android.permission.INTERNET" />

to your app's AndroidManifest.xml file. BugSense uses this permission to send the crash reports and performance metrics.

add the BugSenseHandler in your activity before setContentView. Then you are ready to go!

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BugSenseHandler.initAndStartSession(Context, APIKEY);
    setContentView(R.layout.main);
    //rest of your code here
  }

The InitAndStartSession method installs the BugSense exception handler and the performance monitor. It then sends all the previously saved crash reports and performance metrics. At the same time, it starts a new session for your activity.

Here's an example on how to use the InitAndStartSession:

BugSenseHandler.initAndStartSession(MyActivity.this, "YOURAPIKEY");

Whenever you want to explicitly start the session, you can use the startSession method at the onStart method of your activity, as follows:

BugSenseHandler.startSession(MyActivity.this);

Whenever you want to close the session, you can use the closeSession method as follows:

BugSenseHandler.closeSession(MyActivity.this);

Close session will close the current session, offering better tracking of the sessions for your users.

If you want to manually flush all the saved data, use the BugSenseHandler.flush(Context) method:

BugSenseHandler.flush(MyActivity.this);

More Documentation Android BugSence Doc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!