Here are the examples of the java api android.app.ApplicationErrorReport taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
18
Source : CoreUtils.java
with MIT License
from crazyhitty
with MIT License
from crazyhitty
/**
* Manually create an exception and open system error reporting window.
* Source: https://github.com/DmitryMalkovich/github-replacedytics/blob/master/app/src/main/java/com/dmitrymalkovich/android/githubreplacedytics/util/ActivityUtils.java#L64
*
* @param activity Current activity
*/
public static void openFeedback(Activity activity) {
try {
throw new Exception();
} catch (Exception e) {
ApplicationErrorReport report = new ApplicationErrorReport();
report.packageName = report.processName = activity.getApplication().getPackageName();
report.time = System.currentTimeMillis();
report.type = ApplicationErrorReport.TYPE_CRASH;
report.systemApp = false;
ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
crash.exceptionClreplacedName = e.getClreplaced().getSimpleName();
crash.exceptionMessage = e.getMessage();
StringWriter writer = new StringWriter();
PrintWriter printer = new PrintWriter(writer);
e.printStackTrace(printer);
crash.stackTrace = writer.toString();
StackTraceElement stack = e.getStackTrace()[0];
crash.throwClreplacedName = stack.getClreplacedName();
crash.throwFileName = stack.getFileName();
crash.throwLineNumber = stack.getLineNumber();
crash.throwMethodName = stack.getMethodName();
report.crashInfo = crash;
Intent intent = new Intent(Intent.ACTION_APP_ERROR);
intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
activity.startActivity(intent);
}
}
15
Source : Utils.java
with Apache License 2.0
from DmitryMalkovich
with Apache License 2.0
from DmitryMalkovich
public static void openFeedback(Activity activity) {
try {
throw new IOException();
} catch (IOException e) {
ApplicationErrorReport report = new ApplicationErrorReport();
report.packageName = report.processName = activity.getApplication().getPackageName();
report.time = System.currentTimeMillis();
report.type = ApplicationErrorReport.TYPE_CRASH;
report.systemApp = false;
ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
crash.exceptionClreplacedName = e.getClreplaced().getSimpleName();
crash.exceptionMessage = e.getMessage();
StringWriter writer = new StringWriter();
PrintWriter printer = new PrintWriter(writer);
e.printStackTrace(printer);
crash.stackTrace = writer.toString();
StackTraceElement stack = e.getStackTrace()[0];
crash.throwClreplacedName = stack.getClreplacedName();
crash.throwFileName = stack.getFileName();
crash.throwLineNumber = stack.getLineNumber();
crash.throwMethodName = stack.getMethodName();
report.crashInfo = crash;
Intent intent = new Intent(Intent.ACTION_APP_ERROR);
intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
activity.startActivity(intent);
}
}
12
Source : DynamicLinkUtils.java
with Apache License 2.0
from pranavpandey
with Apache License 2.0
from pranavpandey
/**
* Ask questions or submit bug report to the developer via Google feedback.
*
* <p>It will redirect to {@link #report(Context, String, String)} method if feedback
* package is not available on the device.
*
* @param context The context to retrieve the resources.
* @param appName The app name for the email subject.
* <p>{@code null} to get it from the supplied context.
* @param email The email id of the developer.
* @param reportType The crash report type.
* <p>Can be one of {@link ApplicationErrorReport#TYPE_NONE},
* {@link ApplicationErrorReport#TYPE_CRASH},
* {@link ApplicationErrorReport#TYPE_ANR},
* {@link ApplicationErrorReport#TYPE_BATTERY}, or
* {@link ApplicationErrorReport#TYPE_RUNNING_SERVICE}.
* @param crashInfo The crash info for the report.
*
* @throws ActivityNotFoundException If no activity is found.
*
* @see ApplicationErrorReport
*/
public static void feedback(@NonNull Context context, @Nullable String appName, @NonNull String email, int reportType, @Nullable ApplicationErrorReport.CrashInfo crashInfo) {
ApplicationErrorReport report = new ApplicationErrorReport();
report.packageName = report.processName = context.getPackageName();
report.time = System.currentTimeMillis();
report.type = reportType;
report.systemApp = DynamicPackageUtils.isSystemApp(context.getApplicationInfo());
if (crashInfo != null) {
report.crashInfo = crashInfo;
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
if (isGMSExists(context)) {
intent.setClreplacedName(PACKAGE_GMS, PACKAGE_GMS + ".feedback.FeedbackActivity");
} else {
intent.setClreplacedName(PACKAGE_FEEDBACK, PACKAGE_FEEDBACK + ".FeedbackActivity");
}
try {
context.startActivity(intent);
} catch (Exception e) {
report(context, appName, email);
}
}
10
Source : Util.java
with GNU General Public License v3.0
from OxfordHCC
with GNU General Public License v3.0
from OxfordHCC
public static void sendCrashReport(Throwable ex, final Context context) {
if (!isPlayStoreInstall(context) || Util.isDebuggable(context))
return;
try {
ApplicationErrorReport report = new ApplicationErrorReport();
report.packageName = report.processName = context.getPackageName();
report.time = System.currentTimeMillis();
report.type = ApplicationErrorReport.TYPE_CRASH;
report.systemApp = false;
ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
crash.exceptionClreplacedName = ex.getClreplaced().getSimpleName();
crash.exceptionMessage = ex.getMessage();
StringWriter writer = new StringWriter();
PrintWriter printer = new PrintWriter(writer);
ex.printStackTrace(printer);
crash.stackTrace = writer.toString();
StackTraceElement stack = ex.getStackTrace()[0];
crash.throwClreplacedName = stack.getClreplacedName();
crash.throwFileName = stack.getFileName();
crash.throwLineNumber = stack.getLineNumber();
crash.throwMethodName = stack.getMethodName();
report.crashInfo = crash;
final Intent bug = new Intent(Intent.ACTION_APP_ERROR);
bug.putExtra(Intent.EXTRA_BUG_REPORT, report);
bug.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (bug.resolveActivity(context.getPackageManager()) != null)
context.startActivity(bug);
} catch (Throwable exex) {
Log.e(TAG, exex.toString() + "\n" + Log.getStackTraceString(exex));
}
}