I develop android app but in some cases my app force close
How can I send email to developer contains details if force close
happen in any time ?
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
来源:https://stackoverflow.com/questions/22473374/how-to-send-crash-reports-to-developer