本文整理匯總了Java中org.acra.ACRA類的典型用法代碼示例。如果您正苦於以下問題:Java ACRA類的具體用法?Java ACRA怎麽用?Java ACRA使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ACRA類屬於org.acra包,在下文中一共展示了ACRA類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPathToInstalledApk
import org.acra.ACRA; //導入依賴的package包/類
@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;
}
示例2: hasFDroidSignature
import org.acra.ACRA; //導入依賴的package包/類
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: " + Hex.toHexString(getApkSignature(apkFile)));
Utils.debugLog(TAG, "F-Droid sig: " + Hex.toHexString(getFDroidSignature()));
return false;
}
示例3: send
import org.acra.ACRA; //導入依賴的package包/類
@Override
public void send(CrashReportData report) throws ReportSenderException {
String log = createCrashLog(report);
String url = BASE_URL + ACRA.getConfig().formKey() + CRASHES_PATH;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("raw", log));
parameters.add(new BasicNameValuePair("userID", report.get(ReportField.INSTALLATION_ID)));
parameters.add(new BasicNameValuePair("contact", report.get(ReportField.USER_EMAIL)));
parameters.add(new BasicNameValuePair("description", report.get(ReportField.USER_COMMENT)));
httpPost.setEntity(new UrlEncodedFormEntity(parameters, HTTP.UTF_8));
httpClient.execute(httpPost);
}
catch (Exception e) {
e.printStackTrace();
}
}
示例4: onCreate
import org.acra.ACRA; //導入依賴的package包/類
@Override
public void onCreate() {
ACRA.init(this);
HockeySender crashSender = new HockeySender();
ACRA.getErrorReporter().setReportSender(crashSender);
super.onCreate();
instance = this;
gpsDetector = new GPSDetector();
eventApp = new EventApp();
iriTable = new IRITable();
measurementsDataHelper = new MeasurementsDataHelper();
user = new User();
iriTable.init();
user.restore(this);
initImageLoader();
}
示例5: onHandleIntent
import org.acra.ACRA; //導入依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
final String action = intent.getAction();
if (ACTION_SEND.equals(action)) {
try {
final URL url = new URL(intent.getStringExtra(EXTRA_URL));
final String content = intent.getStringExtra(EXTRA_CONTENT);
final String login = intent.getStringExtra(EXTRA_LOGIN);
final String password = intent.getStringExtra(EXTRA_PASSWORD);
ACRAConfiguration config = ACRA.getConfig();
send(url, config.httpMethod(), content, login, password);
} catch (IOException e) {
Log.e("HttpSenderService", "url", e);
}
}
}
}
示例6: open
import org.acra.ACRA; //導入依賴的package包/類
private void open() {
// Intent i = new Intent(META_CHANGED);
// sendStickyBroadcast(i);
Bundle extras = new Bundle();
extras.putInt(EXTRA_POSITION, getPositionWithinPlayList());
sendBroadcast(POSITION_CHANGED, extras);
mMediaPlayer.reset();
Uri songUri = ContentUris.withAppendedId(
android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
mCurrentSong.getId());
try {
mMediaPlayer.setDataSource(getApplicationContext(), songUri);
mMediaPlayer.prepareAsync();
} catch (IllegalArgumentException | SecurityException
| IllegalStateException | IOException e) {
ACRA.getErrorReporter().handleException(e);
Log.e("ee", "ee", e);
}
}
示例7: createFile
import org.acra.ACRA; //導入依賴的package包/類
private static RequestFile createFile(Context context, Uri uri) {
RequestFile requestFile = null;
Log.d(LOG_TAG, "createFile " + uri);
try {
InputStream inputStream = null;
String name = getFileName(context, uri);
String extension = MimeTypeUtil.getExtension(name);
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (mimeType == null) {
mimeType = context.getContentResolver().getType(uri);
}
if (mimeType == null) {
mimeType = MimeTypeUtil.getType(extension);
}
if (uri.getScheme().equals("content")) {
inputStream = context.getContentResolver().openInputStream(uri);
} else if (uri.getScheme().equals("file")) {
inputStream = new FileInputStream(new File(uri.getPath()));
}
requestFile = new RequestFile(name, mimeType, inputStream);
} catch (Exception e) {
ACRA.getErrorReporter().handleException(e);
}
return requestFile;
}
示例8: onCreate
import org.acra.ACRA; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
String language, country;
defaultLocale = Locale.getDefault();
SharedPreferences pref = getSharedPreferences("pref", MODE_PRIVATE);
String[] pref_locale = pref.getString(PREF_KCA_LANGUAGE, "").split("-");
if (pref_locale.length == 2) {
if (pref_locale[0].equals("default")) {
LocaleUtils.setLocale(defaultLocale);
} else {
language = pref_locale[0];
country = pref_locale[1];
LocaleUtils.setLocale(new Locale(language, country));
}
} else {
pref.edit().remove(PREF_KCA_LANGUAGE).apply();
LocaleUtils.setLocale(defaultLocale);
}
LocaleUtils.updateConfig(this, getBaseContext().getResources().getConfiguration());
ACRA.init(this);
}
示例9: upgrade
import org.acra.ACRA; //導入依賴的package包/類
public void upgrade() {
Log.d("doInBackground(): Loading data and running migration if necessary");
try {
// invalidate database (protects against crash when database swapped while application paused - generally for testing)
MeasurementsDatabase.invalidateInstance(MyApplication.getApplication());
long startTime = System.currentTimeMillis();
// one of below will trigger data migration if necessary (long operation)
MeasurementsDatabase.getInstance(MyApplication.getApplication()).forceDatabaseUpgrade();
AnalyticsStatistics stats = MeasurementsDatabase.getInstance(MyApplication.getApplication()).getAnalyticsStatistics();
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime);
MyApplication.getAnalytics().sendMigrationFinished(duration, oldDbVersion, stats);
} catch (RuntimeException ex) {
Log.e("doInBackground(): Database migration crashed", ex);
MyApplication.getAnalytics().sendException(ex, Boolean.TRUE);
ACRA.getErrorReporter().handleSilentException(ex);
throw ex;
}
}
示例10: getPreference
import org.acra.ACRA; //導入依賴的package包/類
public T getPreference(int valueKey, int defaultValueKey) {
T value;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
T defaultValue = getPreferenceDefaultValue(defaultValueKey);
try {
value = getPreferenceValue(prefs, valueKey, defaultValue);
Log.d(getLogTag(), String.format("getPreference(): Preference `%s` loaded with value `%s`", context.getString(valueKey), value));
} catch (ClassCastException ex) {
Log.e(getLogTag(), String.format("getPreference(): Error while loading preference `%s`, restoring default", context.getString(valueKey), ex));
MyApplication.getAnalytics().sendException(ex, Boolean.FALSE);
ACRA.getErrorReporter().handleSilentException(ex);
value = defaultValue;
SharedPreferences.Editor editor = prefs.edit();
setPreferenceValue(editor, valueKey, defaultValue);
editor.commit();
}
return value;
}
示例11: displayUploadResultDialog
import org.acra.ACRA; //導入依賴的package包/類
private void displayUploadResultDialog(Bundle extras) {
int descriptionId = extras.getInt(UploaderService.INTENT_KEY_RESULT_DESCRIPTION);
try {
String descriptionContent = getString(descriptionId);
Log.d("displayUploadResultDialog(): Received extras: %s", descriptionId);
// display dialog
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.setCancelable(true);
alertDialog.setTitle(R.string.uploader_result_dialog_title);
alertDialog.setMessage(descriptionContent);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
} catch (NotFoundException ex) {
Log.w("displayUploadResultDialog(): Invalid string id received with intent extras: %s", descriptionId);
MyApplication.getAnalytics().sendException(ex, Boolean.FALSE);
ACRA.getErrorReporter().handleSilentException(ex);
}
}
示例12: initACRA
import org.acra.ACRA; //導入依賴的package包/類
private void initACRA() {
Log.d("initACRA(): Initializing ACRA");
CoreConfigurationBuilder configBuilder = new CoreConfigurationBuilder(this);
// Configure connection
configBuilder.setBuildConfigClass(BuildConfig.class);
configBuilder.setSendReportsInDevMode(BuildConfig.ACRA_SEND_REPORTS_IN_DEV_MODE);
configBuilder.setReportFormat(StringFormat.valueOf(BuildConfig.ACRA_REPORT_TYPE));
configBuilder.setExcludeMatchingSharedPreferencesKeys(new String[]{"api_key"});
configBuilder.setReportContent(getCustomAcraReportFields());
// Configure reported content
HttpSenderConfigurationBuilder httpPluginConfigBuilder = configBuilder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class);
httpPluginConfigBuilder.setUri(BuildConfig.ACRA_FORM_URI);
httpPluginConfigBuilder.setBasicAuthLogin(BuildConfig.ACRA_FORM_URI_BASIC_AUTH_LOGIN);
httpPluginConfigBuilder.setBasicAuthPassword(BuildConfig.ACRA_FORM_URI_BASIC_AUTH_PASSWORD);
httpPluginConfigBuilder.setHttpMethod(HttpSender.Method.valueOf(BuildConfig.ACRA_HTTP_METHOD));
httpPluginConfigBuilder.setEnabled(true);
ACRA.init(this, configBuilder);
}
示例13: onCreate
import org.acra.ACRA; //導入依賴的package包/類
@Override
public void onCreate() {
if (Configuration.IS_EINK_DEVICE) { // e-ink looks better with dark-on-light (esp. Nook Touch where theming breaks light-on-dark
setTheme(R.style.Theme_AppCompat_Light);
//This is a work-around because unit-tests call ACRA more than once.
if (!acraInitDone) {
ACRA.init(this);
acraInitDone = true;
}
}
super.onCreate();
instance = this;
}
示例14: bindView
import org.acra.ACRA; //導入依賴的package包/類
@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
final String label = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_LABEL));
final String coinId = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_COIN_ID));
final String addressStr = cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS));
CoinType type = CoinID.typeFromId(coinId);
final ViewGroup viewGroup = (ViewGroup) view;
final TextView labelView = (TextView) viewGroup.findViewById(R.id.address_book_row_label);
labelView.setText(label);
final TextView addressView = (TextView) viewGroup.findViewById(R.id.address_book_row_address);
try {
addressView.setText(GenericUtils.addressSplitToGroupsMultiline(type.newAddress(addressStr)));
} catch (AddressMalformedException e) {
ACRA.getErrorReporter().handleSilentException(e);
addressView.setText(addressStr);
}
}
示例15: onAddCoinTaskFinished
import org.acra.ACRA; //導入依賴的package包/類
@Override
public void onAddCoinTaskFinished(Exception error, WalletAccount newAccount) {
if (Dialogs.dismissAllowingStateLoss(getFragmentManager(), ADD_COIN_TASK_BUSY_DIALOG_TAG)) return;
if (error != null) {
if (error instanceof KeyCrypterException) {
showPasswordRetryDialog();
} else {
ACRA.getErrorReporter().handleSilentException(error);
Toast.makeText(getActivity(), com.fillerino.wallet.R.string.error_generic, Toast.LENGTH_LONG).show();
}
} else {
destinationAccount = newAccount;
destinationType = newAccount.getCoinType();
onHandleNext();
}
addCoinAndProceedTask = null;
}