src/main/java/org/acra/ACRA.java
/**
     * <p>
     * Initialize ACRA for a given Application. The call to this method should
     * be placed as soon as possible in the {@link Application#onCreate()}
     * method.
     * </p>
     * 
     * @param app
     *            Your Application class.
     * @throws IllegalStateException
     *             if it is called more than once.
     */

Initialize ACRA for a given Application. The call to this method should
be placed as soon as possible in the  Application#onCreate()
method.

@param app
Your Application class.
@throws IllegalStateException
if it is called more than once.
Initialize ACRA for a given Application . The call to this method should be placed as soon as possible in the Application#onCreate () method . @param app Your Application class . @throws IllegalStateException if it is called more than once .
public static void init(Application app) {
        if (mApplication != null) {
            throw new IllegalStateException("ACRA#init called more than once");
        }
        mApplication = app;
        mReportsCrashes = mApplication.getClass().getAnnotation(ReportsCrashes.class);
        if (mReportsCrashes == null) {
            Log.e(LOG_TAG,
                    "ACRA#init called but no ReportsCrashes annotation on Application " + mApplication.getPackageName());
            return;
        }
        final SharedPreferences prefs = getACRASharedPreferences();
        Log.d(ACRA.LOG_TAG, "Set OnSharedPreferenceChangeListener.");
        try {
            checkCrashResources();
            Log.d(LOG_TAG, "ACRA is enabled for " + mApplication.getPackageName() + ", intializing...");
            final boolean enableAcra = !shouldDisableACRA(prefs);
            final ErrorReporter errorReporter = new ErrorReporter(mApplication.getApplicationContext(), prefs,
                    enableAcra);
            addReportSenders(errorReporter);
            errorReporterSingleton = errorReporter;
        } catch (ACRAConfigurationException e) {
            Log.w(LOG_TAG, "Error : ", e);
        }
        mPrefListener = new OnSharedPreferenceChangeListener() {
            @Override
            public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
                if (PREF_DISABLE_ACRA.equals(key) || PREF_ENABLE_ACRA.equals(key)) {
                    final boolean enableAcra = !shouldDisableACRA(sharedPreferences);
                    getErrorReporter().setEnabled(enableAcra);
                }
            }
        };
        prefs.registerOnSharedPreferenceChangeListener(mPrefListener);
    }
public static void init ( Application app ) { if ( mApplication != null ) { throw new IllegalStateException ( "ACRA#init called more than once" ) ; } mApplication = app ; mReportsCrashes = mApplication . getClass ( ) . getAnnotation ( ReportsCrashes . class ) ; if ( mReportsCrashes == null ) { Log . e ( LOG_TAG , "ACRA#init called but no ReportsCrashes annotation on Application " + mApplication . getPackageName ( ) ) ; return ; } final SharedPreferences prefs = getACRASharedPreferences ( ) ; Log . d ( ACRA . LOG_TAG , "Set OnSharedPreferenceChangeListener." ) ; try { checkCrashResources ( ) ; Log . d ( LOG_TAG , "ACRA is enabled for " + mApplication . getPackageName ( ) + ", intializing..." ) ; final boolean enableAcra = ! shouldDisableACRA ( prefs ) ; final ErrorReporter errorReporter = new ErrorReporter ( mApplication . getApplicationContext ( ) , prefs , enableAcra ) ; addReportSenders ( errorReporter ) ; errorReporterSingleton = errorReporter ; } catch ( ACRAConfigurationException e ) { Log . w ( LOG_TAG , "Error : " , e ) ; } mPrefListener = new OnSharedPreferenceChangeListener ( ) { @ Override public void onSharedPreferenceChanged ( SharedPreferences sharedPreferences , String key ) { if ( PREF_DISABLE_ACRA . equals ( key ) || PREF_ENABLE_ACRA . equals ( key ) ) { final boolean enableAcra = ! shouldDisableACRA ( sharedPreferences ) ; getErrorReporter ( ) . setEnabled ( enableAcra ) ; } } } ; prefs . registerOnSharedPreferenceChangeListener ( mPrefListener ) ; }
<p>
 Initialize ACRA for a given Application.
<p > Initialize ACRA for a given Application .
// Initialize ErrorReporter with all required data
 // Append ReportSenders.
 // We HAVE to keep a reference otherwise the listener could be garbage
 // collected:
 // http://stackoverflow.com/questions/2542938/sharedpreferences-onsharedpreferencechangelistener-not-being-called-consistently/3104265#3104265
 // This listener has to be set after initAcra is called to avoid a
 // NPE in ErrorReporter.disable() because
 // the context could be null at this moment.
