org.acra.ACRA Java Examples

The following examples show how to use org.acra.ACRA. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeopaparazziApplication.java    From geopaparazzi with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    try {

        ACRAConfiguration config = new ConfigurationBuilder(this) //
                .setMailTo(mailTo)//
                .setCustomReportContent(//
                        ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, //
                        ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, //
                        ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT) //
                .setResToastText(R.string.crash_toast_text)//
                .setLogcatArguments("-t", "400", "-v", "time", "GPLOG:I", "*:S") //
                .setReportingInteractionMode(ReportingInteractionMode.TOAST)//
                .build();


        ACRA.init(this, config);
    } catch (ACRAConfigurationException e) {
        e.printStackTrace();
    }
}
 
Example #2
Source File: InstalledAppProviderService.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
public static File getPathToInstalledApk(PackageInfo packageInfo) {
    File apk = new File(packageInfo.applicationInfo.publicSourceDir);
    if (apk.isDirectory()) {
        FilenameFilter filter = new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".apk");
            }
        };
        File[] files = apk.listFiles(filter);
        if (files == null) {
            String msg = packageInfo.packageName + " sourceDir has no APKs: " + apk.getAbsolutePath();
            Utils.debugLog(TAG, msg);
            ACRA.getErrorReporter().handleException(new IllegalArgumentException(msg), false);
            return null;
        }
        apk = files[0];
    }

    return apk;
}
 
Example #3
Source File: ApkSignatureVerifier.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
public boolean hasFDroidSignature(File apkFile) {
    if (!apkFile.exists()) {
        ACRA.getErrorReporter().handleException(
                new Exception("Failed to install Privileged Extension, because " + apkFile.getAbsolutePath()
                        + " does not exist."),
                false
        );

        return false;
    }

    byte[] apkSig = getApkSignature(apkFile);
    byte[] fdroidSig = getFDroidSignature();

    if (Arrays.equals(apkSig, fdroidSig)) {
        return true;
    }

    Utils.debugLog(TAG, "Signature mismatch!");
    Utils.debugLog(TAG, "APK sig: " + Utils.toHexString(getApkSignature(apkFile)));
    Utils.debugLog(TAG, "F-Droid sig: " + Utils.toHexString(getFDroidSignature()));
    return false;
}
 
Example #4
Source File: App.java    From video-transcoder with GNU General Public License v3.0 6 votes vote down vote up
private void initACRA()
{
    try
    {
        final ACRAConfiguration acraConfig = new ConfigurationBuilder(this)
                .setReportSenderFactoryClasses(reportSenderFactoryClasses)
                .setBuildConfigClass(BuildConfig.class)
                .build();
        ACRA.init(this, acraConfig);
    }
    catch (ACRAConfigurationException ace)
    {
        ErrorActivity.reportError(this, ace, null, ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
                "Could not initialize ACRA crash report", R.string.app_ui_crash));
    }
}
 
Example #5
Source File: MyApplication.java    From FaceSlim with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onCreate() {
    mContext = getApplicationContext();
    super.onCreate();

    /**
     * The following line triggers the initialization of ACRA.
     */
    ACRA.init(this);

    /**
     * Piwik dry run. Uncomment these lines during app development.
     */
    Piwik.getInstance(this).setDryRun(BuildConfig.DEBUG);
    Piwik.getInstance(this).setDebug(BuildConfig.DEBUG);

    /**
     * Count app downloads. Fired only after new installation or upgrade.
     * It's never fired again. In fact the app is not tracking anything but installations.
     */
    if (Connectivity.isConnected(this)) {
        getTracker().trackAppDownload();
        getTracker().dispatch();
    }
}
 
Example #6
Source File: TVPortalApplication.java    From android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    ACRA.init(this);
    SharedPreferences mPrefs;
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mPrefs.edit().putInt(ARG_LAUNCH_COUNT, (mPrefs.getInt(ARG_LAUNCH_COUNT, 0)) + 1).apply();
    //google analytics minimal just amount of install's and sessions
    mTracker = GoogleAnalytics.getInstance(this).getTracker(Config.GA_PROPERTY_ID);
    mTracker.send(MapBuilder.createEvent("UX", "appstart", null, null)
                    .set(Fields.SESSION_CONTROL, "start")
                    .build()
    );
    //Check if the user upgraded via the server:
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... voids) {
            AppUtils.isServerUpgraded(TVPortalApplication.this);
            return null;
        }
    }.execute();

}
 
Example #7
Source File: FeedbackActivity.java    From BaldPhone with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feedback);
    final EditText et_feedback = findViewById(R.id.et_feedback);
    findViewById(R.id.bt_send).setOnClickListener(v -> {
        final CharSequence text = et_feedback.getText();
        if (text.length() == 0)
            BaldToast.from(v.getContext()).setType(BaldToast.TYPE_ERROR).setText(R.string.feedback_cannot_be_empty).show();
        else {
            ACRA.getErrorReporter().handleSilentException(new FeedbackException(String.valueOf(text)));
            BaldToast.from(getApplicationContext()).setText(R.string.feedback_sent_successfully).show();
            finish();
        }
    });
}
 
Example #8
Source File: OsPreferenceActivity.java    From Onosendai with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate (final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	final ActionBar ab = getActionBar();
	ab.setDisplayHomeAsUpEnabled(true);

	if (hasHeaders()) {
		final LayoutInflater inflater = LayoutInflater.from(this);
		final Button btn = (Button) inflater.inflate(R.layout.buttonbarbutton, null, false);
		btn.setText("Report a problem"); //ES
		btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick (final View v) {
				ACRA.getErrorReporter().handleException(null);
			}
		});
		setListFooter(btn);
	}
}
 
Example #9
Source File: BaldPhone.java    From BaldPhone with Apache License 2.0 6 votes vote down vote up
@Override
protected void attachBaseContext(final Context base) {
    super.attachBaseContext(base);
    final CoreConfigurationBuilder builder =
            new CoreConfigurationBuilder(this)
                    .setBuildConfigClass(BuildConfig.class)
                    .setReportFormat(StringFormat.JSON);
    builder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class)
            .setUri(getString(R.string.tt_url))
            .setHttpMethod(HttpSender.Method.POST)
            .setEnabled(true);
    ACRA.init(this, builder);

    Thread.setDefaultUncaughtExceptionHandler(
            new BaldUncaughtExceptionHandler(this, Thread.getDefaultUncaughtExceptionHandler())
    );
}
 
Example #10
Source File: Basics.java    From trackworktime with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Wrapper for {@link #checkLocationBasedTracking()} that doesn't throw any exception.
 */
public void safeCheckLocationBasedTracking() {
	try {
		checkLocationBasedTracking();
	} catch (Exception e) {
		e.printStackTrace();
		ACRA.getErrorReporter().handleException(e);
	}
}
 
Example #11
Source File: Basics.java    From trackworktime with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Wrapper for {@link #checkPersistentNotification()} that doesn't throw any exception.
 */
public void safeCheckPersistentNotification() {
	try {
		checkPersistentNotification();
	} catch (Exception e) {
		e.printStackTrace();
		ACRA.getErrorReporter().handleException(e);
	}
}
 
Example #12
Source File: MyApplication.java    From TowerCollector with Mozilla Public License 2.0 5 votes vote down vote up
public synchronized static void handleSilentException(Throwable throwable) {
    String throwableHash = HashUtils.toSha1(throwable.toString());
    if (!handledSilentExceptionHashes.contains(throwableHash)) {
        handledSilentExceptionHashes.add(throwableHash);
        ACRA.getErrorReporter().handleSilentException(throwable);
    }
}
 
Example #13
Source File: Basics.java    From trackworktime with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Wrapper for {@link #checkWifiBasedTracking()} that doesn't throw any exception.
 */
public void safeCheckWifiBasedTracking() {
	try {
		checkWifiBasedTracking();
	} catch (Exception e) {
		e.printStackTrace();
		ACRA.getErrorReporter().handleException(e);
	}
}
 
Example #14
Source File: Application.java    From DistroHopper with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void attachBaseContext(final Context base) {
	super.attachBaseContext(base);

	// The following line triggers the initialization of ACRA
	ACRA.init(this);
}
 
Example #15
Source File: ExceptionHandler.java    From DistroHopper with GNU General Public License v3.0 5 votes vote down vote up
private void track(final Throwable ex) {
	try {
		ACRA.getErrorReporter().handleSilentException(ex);
	} catch (Exception ex2) {
		Log.getInstance ().w (this.getClass ().getSimpleName (), "Problem description couldn't be sent: " + ex2.getMessage ());
	}
}
 
Example #16
Source File: OsmApplication.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);

    try {
        // Initialise ACRA
        ACRA.init(this);
        ACRA.getErrorReporter().setReportSender(new ErrorFileWriter());
    } catch (Throwable t) {
        t.printStackTrace();
        //this can happen on androidx86 getExternalStorageDir is not writable or if there is a
        //permissions issue
    }
}
 
Example #17
Source File: AbstractRycApplication.java    From remoteyourcam-usb with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    if (AppConfig.USE_ACRA) {
        try {
            ACRA.init(this);
        } catch (Throwable e) {
            // no fail
        }
    }
    super.onCreate();
}
 
Example #18
Source File: AcraSampleApplication.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    ACRA.init(this);
    
    //Custom Senderをセットする
    //ACRA.getErrorReporter().setReportSender(new MySender());
    super.onCreate();
}
 
Example #19
Source File: Onosendai.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate () {
	super.onCreate();
	ACRA.init(this);
	addBuildNumberToCrashReport();
	LOG.i("RT.maxMemory=%s", Runtime.getRuntime().maxMemory());
	loadAndSetLocale(null);
}
 
Example #20
Source File: Onosendai.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
private void addBuildNumberToCrashReport () {
	try {
		final String buildNumber = IoHelper.toString(getClass().getResourceAsStream("/build_number"));
		ACRA.getErrorReporter().putCustomData("BUILD_NUMBER", buildNumber);
	}
	catch (final IOException e) {
		Log.w(C.TAG, "Failed to read BUILD_NUMBER: " + e.toString());
	}
}
 
Example #21
Source File: AndFChatApplication.java    From AndFChat with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Intent serviceIntent = new Intent(this, AndFChatConnectionService.class);
    bindService(serviceIntent, networkServiceConnection, Context.BIND_AUTO_CREATE);

    // The following line triggers the initialization of ACRA
    ACRA.init(this);
}
 
Example #22
Source File: Basics.java    From trackworktime with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Wrapper for {@link PreferencesUtil#checkAllPreferenceSections()} that doesn't throw any exception.
 */
private void safeCheckPreferences() {
	try {
		PreferencesUtil.checkAllPreferenceSections();
	} catch (Exception e) {
		e.printStackTrace();
		ACRA.getErrorReporter().handleException(e);
	}
}
 
Example #23
Source File: ContentProviderHelper.java    From ContentProviderHelper with MIT License 5 votes vote down vote up
public static void handleException(Context context, Exception e, boolean sendReport) {
	e.printStackTrace();
	Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
	if (sendReport) {
		ACRA.getErrorReporter().handleException(e);
	}
}
 
Example #24
Source File: ContentProviderHelper.java    From ContentProviderHelper with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();

	ACRA.init(this);
	PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
}
 
Example #25
Source File: App.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    if (!ACRA.isACRASenderServiceProcess()) {
        ACRA.init(this);

    }
}
 
Example #26
Source File: LevelsManager.java    From gravitydefied with GNU General Public License v2.0 5 votes vote down vote up
public void reload() {
	long id = Settings.getLevelId();
	currentLevel = dataSource.getLevel(id);

	if (currentLevel == null) {
		logDebug("LevelsManager: failed to load currentLevel; currentId = " + id);
	} else {
		logDebug("LevelsManager: level = " + currentLevel);
	}

	if (Global.ACRA_ENABLED) {
		ACRA.getErrorReporter().putCustomData("level_api_id:", String.valueOf(currentLevel.getApiId()));
	}
}
 
Example #27
Source File: MainApplication.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (ACRAConstants.ACRA_ENABLED) ACRA.init(this);
    if (isGalleryProcess()) return;
    initObjects();
    instance = this;
}
 
Example #28
Source File: MosMetroApp.java    From mosmetro-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    ACRA.init(this);

    if (!ACRA.isACRASenderServiceProcess()) {
        Logger.configure(base);
    }
}
 
Example #29
Source File: AppController.java    From Instagram-Profile-Downloader with MIT License 5 votes vote down vote up
private void initACRA() {
    try {
        final ACRAConfiguration acraConfig = new ConfigurationBuilder(this)
                .setReportSenderFactoryClasses(reportSenderFactoryClasses)
                .setBuildConfigClass(BuildConfig.class)
                .build();
        ACRA.init(this, acraConfig);
    } catch (ACRAConfigurationException ace) {
        ace.printStackTrace();
        ErrorActivity.reportError(this,
                ace,
                null,
                null,
                ErrorActivity.ErrorInfo.make(UserAction.SOMETHING_ELSE, "none",
                        "Could not initialize ACRA crash report", R.string.app_ui_crash));
    }
}
 
Example #30
Source File: SettingsActivity.java    From mosmetro-android with GNU General Public License v3.0 5 votes vote down vote up
private void replaceFragment(String id, Fragment fragment) {
    try {
        getFragmentManager()
                .beginTransaction()
                .replace(android.R.id.content, fragment)
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .addToBackStack(id)
                .commit();
    } catch (IllegalStateException ex) { // https://stackoverflow.com/q/7575921
        ACRA.getErrorReporter().handleException(ex);
    }
}