资源简介

Android崩溃时,使用自己的错误页面,提高友好度

资源截图

代码片段和文件信息

/*
 * Copyright 2015 Eduard Ereza Martínez
 *
 * Licensed under the Apache License Version 2.0 (the “License“);
 * you may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing software
 * distributed under the License is distributed on an “AS IS“ BASIS
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cat.ereza.customactivityoncrash;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.lang.reflect.Modifier;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import cat.ereza.customactivityoncrash.activity.DefaultErrorActivity;

@SuppressLint(“NewApi“)
public final class CustomActivityOnCrash {

    private final static String TAG = “CustomActivityOnCrash“;

    //Extras passed to the error activity
    private static final String EXTRA_RESTART_ACTIVITY_CLASS = “cat.ereza.customactivityoncrash.EXTRA_RESTART_ACTIVITY_CLASS“;
    private static final String EXTRA_SHOW_ERROR_DETAILS = “cat.ereza.customactivityoncrash.EXTRA_SHOW_ERROR_DETAILS“;
    private static final String EXTRA_STACK_TRACE = “cat.ereza.customactivityoncrash.EXTRA_STACK_TRACE“;
    private static final String EXTRA_IMAGE_DRAWABLE_ID = “cat.ereza.customactivityoncrash.EXTRA_IMAGE_DRAWABLE_ID“;
    private static final String EXTRA_EVENT_LISTENER = “cat.ereza.customactivityoncrash.EXTRA_EVENT_LISTENER“;

    //General constants
    private static final String INTENT_ACTION_ERROR_ACTIVITY = “cat.ereza.customactivityoncrash.ERROR“;
    private static final String INTENT_ACTION_RESTART_ACTIVITY = “cat.ereza.customactivityoncrash.RESTART“;
    private static final String CAOC_HANDLER_PACKAGE_NAME = “cat.ereza.customactivityoncrash“;
    private static final String DEFAULT_HANDLER_PACKAGE_NAME = “com.android.internal.os“;
    private static final int MAX_STACK_TRACE_SIZE = 131071; //128 KB - 1
    private static final int TIMESTAMP_DIFFERENCE_TO_AVOID_RESTART_LOOPS_IN_MILLIS = 2000;

    //Shared preferences
    private static final String SHARED_PREFERENCES_FILE = “custom_activity_on_crash“;
    private static final String SHARED_PREFERENCES_FIELD_TIMESTAMP = “las

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\
     文件          76  2016-03-09 20:32  CustomActivityOnCrash-master\.gitignore
     文件       11357  2016-03-09 20:32  CustomActivityOnCrash-master\LICENSE
     文件         224  2016-03-09 20:32  CustomActivityOnCrash-master\NOTICE
     文件       11571  2016-03-09 20:32  CustomActivityOnCrash-master\README.md
     文件        1039  2016-03-09 20:32  CustomActivityOnCrash-master\build.gradle
     文件        1537  2016-03-09 20:32  CustomActivityOnCrash-master\gradle.properties
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\gradle\
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\gradle\wrapper\
     文件       49896  2016-03-09 20:32  CustomActivityOnCrash-master\gradle\wrapper\gradle-wrapper.jar
     文件         232  2016-03-09 20:32  CustomActivityOnCrash-master\gradle\wrapper\gradle-wrapper.properties
     文件        5080  2016-03-09 20:32  CustomActivityOnCrash-master\gradlew
     文件        2314  2016-03-09 20:32  CustomActivityOnCrash-master\gradlew.bat
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\images\
     文件       34025  2016-03-09 20:32  CustomActivityOnCrash-master\images\frontpage.png
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\
     文件           7  2016-03-09 20:32  CustomActivityOnCrash-master\library\.gitignore
     文件         978  2016-03-09 20:32  CustomActivityOnCrash-master\library\build.gradle
     文件         684  2016-03-09 20:32  CustomActivityOnCrash-master\library\gradle.properties
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\
     文件        1010  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\AndroidManifest.xml
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\java\
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\java\cat\
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\java\cat\ereza\
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\java\cat\ereza\customactivityoncrash\
     文件       37423  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\java\cat\ereza\customactivityoncrash\CustomActivityOnCrash.java
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\java\cat\ereza\customactivityoncrash\activity\
     文件        6247  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\java\cat\ereza\customactivityoncrash\activity\DefaultErrorActivity.java
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\res\
     目录           0  2016-03-09 20:32  CustomActivityOnCrash-master\library\src\main\res\drawable-hdpi\
............此处省略58个文件信息

评论

共有 条评论