diff --git a/library/src/main/java/cat/ereza/customactivityoncrash/activity/DefaultErrorActivity.java b/library/src/main/java/cat/ereza/customactivityoncrash/activity/DefaultErrorActivity.java
index b125d5e..0a68cf3 100644
--- a/library/src/main/java/cat/ereza/customactivityoncrash/activity/DefaultErrorActivity.java
+++ b/library/src/main/java/cat/ereza/customactivityoncrash/activity/DefaultErrorActivity.java
@@ -16,15 +16,21 @@
package cat.ereza.customactivityoncrash.activity;
+import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
+import android.widget.Toast;
import cat.ereza.customactivityoncrash.CustomActivityOnCrash;
import cat.ereza.customactivityoncrash.R;
@@ -75,6 +81,13 @@ public void onClick(View v) {
.setTitle(R.string.customactivityoncrash_error_activity_error_details_title)
.setMessage(CustomActivityOnCrash.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent()))
.setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null)
+ .setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy,
+ new DialogInterface.OnClickListener() {
+ @Override public void onClick(DialogInterface dialog, int which) {
+ copyErrorToClipboard();
+ Toast.makeText(DefaultErrorActivity.this, R.string.customactivityoncrash_error_activity_error_details_copied, Toast.LENGTH_SHORT).show();
+ }
+ })
.show();
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
@@ -84,4 +97,19 @@ public void onClick(View v) {
moreInfoButton.setVisibility(View.GONE);
}
}
+
+ @SuppressLint("NewApi")
+ private void copyErrorToClipboard() {
+ String errorInformation =
+ CustomActivityOnCrash.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent());
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
+ clipboard.setText(errorInformation);
+ } else {
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText("Error information", errorInformation);
+ clipboard.setPrimaryClip(clip);
+ }
+ }
}
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
index 00c57aa..9456ec9 100644
--- a/library/src/main/res/values/strings.xml
+++ b/library/src/main/res/values/strings.xml
@@ -22,4 +22,6 @@
Error details
Error details
Close
+ Copy to clipboard
+ Copied to clipboard