Java Code Examples for com.crashlytics.android.Crashlytics#logException()

The following examples show how to use com.crashlytics.android.Crashlytics#logException() . 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: DocumentsActivity.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@Override
protected Uri doInBackground(Void... params) {
    final ContentResolver resolver = getContentResolver();
    final DocumentInfo cwd = getCurrentDirectory();

    ContentProviderClient client = null;
    Uri childUri = null;
    try {
        client = DocumentsApplication.acquireUnstableProviderOrThrow(
                resolver, cwd.derivedUri.getAuthority());
        childUri = DocumentsContract.createDocument(
        		resolver, cwd.derivedUri, mMimeType, mDisplayName);
    } catch (Exception e) {
        Log.w(TAG, "Failed to create document", e);
        Crashlytics.logException(e);
    } finally {
    	ContentProviderClientCompat.releaseQuietly(client);
    }

    if (childUri != null) {
        saveStackBlocking();
    }

    return childUri;
}
 
Example 2
Source File: CrashReportTree.java    From android-mvp-starter with MIT License 6 votes vote down vote up
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    if (priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO) {
        return;
    }

    Crashlytics.setInt(CRASHLYTICS_KEY_PRIORITY, priority);
    Crashlytics.setString(CRASHLYTICS_KEY_TAG, tag);
    Crashlytics.setString(CRASHLYTICS_KEY_MESSAGE, message);

    if (t == null) {
        Crashlytics.logException(new Exception(message));
    } else {
        Crashlytics.logException(t);
    }
}
 
Example 3
Source File: PrefsManager.java    From Kernel-Tuner with GNU General Public License v3.0 6 votes vote down vote up
public static String getCpuGovernor(int core)
{
    try
    {
        //i accidentally put this as int, so this is a workaround
        return prefs.getString("cpu_" + core + "_governor", null);
    }
    catch (Exception e)
    {
        e.printStackTrace();
        Crashlytics.logException(e);
        SharedPreferences.Editor editor = prefs.edit();
        editor.remove("cpu_" + core + "_governor");
        editor.apply();
    }
    return null;
}
 
Example 4
Source File: ContributorsActivity.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
private void renderSavedContributors(Throwable throwable) {
    Log.e(TAG, "Failed to fetchContributors.", throwable);
    Crashlytics.logException(throwable);

    List<Contributor> contributors = dao.findAll();

    if (contributors.isEmpty()) {
        Snackbar.make(binding.getRoot(), R.string.contributors_load_error, Snackbar.LENGTH_LONG).show();
    } else {
        bindContributors(contributors);
    }
}
 
Example 5
Source File: NetworkConnection.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public String getHomeDirectory() {
    if (path == null) {
        try {
            connectClient();
        } catch (IOException e) {
            LogUtils.LOGD(TAG, "Error getting home dir:"+ e);
            Crashlytics.logException(e);
        }
    }
    return path;
}
 
Example 6
Source File: AIDLDumper.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
public SongBean getNextSong() {
    PlayerServiceAIDL service = getService();
    SongBean ret = null;
    try {
        ret = service.getNextSong();
    } catch (Exception e) {
        Logger.dExp(e);
        Crashlytics.logException(e);
    }
    return ret;
}
 
Example 7
Source File: DetailFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
protected Void doInBackground(Void... params) {
	filePath = doc.path;

	if (!Utils.isDir(doc.mimeType)) {
              final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, doc.mimeType);
		int thumbSize = getResources().getDimensionPixelSize(R.dimen.grid_width);
		Point mThumbSize = new Point(thumbSize, thumbSize);
		final Uri uri = DocumentsContract.buildDocumentUri(doc.authority, doc.documentId);
		final Context context = getActivity();
		final ContentResolver resolver = context.getContentResolver();
		ContentProviderClient client = null;
		try {

			if (doc.mimeType.equals(Document.MIME_TYPE_APK) && !TextUtils.isEmpty(filePath)) {
				result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context, filePath, Document.MIME_TYPE_APK)).getBitmap();
			} else {
				client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, uri.getAuthority());
				result = DocumentsContract.getDocumentThumbnail(resolver, uri, mThumbSize, null);
			}
		} catch (Exception e) {
			if (!(e instanceof OperationCanceledException)) {
				Log.w(TAG_DETAIL, "Failed to load thumbnail for " + uri + ": " + e);
			}
			Crashlytics.logException(e);
		} finally {
			ContentProviderClientCompat.releaseQuietly(client);
		}

		sizeString = Formatter.formatFileSize(context, doc.size);
	}
	else{
		if(!TextUtils.isEmpty(filePath)){
			File dir = new File(filePath);
			sizeString = Formatter.formatFileSize(getActivity(), Utils.getDirectorySize(dir));
		}				
	}
	
	return null;
}
 
Example 8
Source File: Entity.java    From homeassist with Apache License 2.0 5 votes vote down vote up
public static Entity getInstance(Cursor cursor) {
    Entity entity = null;
    try {
        entity = CommonUtil.inflate(cursor.getString(cursor.getColumnIndex("RAW_JSON")), Entity.class);
        entity.checksum = cursor.getString(cursor.getColumnIndex("CHECKSUM"));
        if (cursor.getColumnIndex("DISPLAY_ORDER") != -1) {
            entity.displayOrder = cursor.getInt(cursor.getColumnIndex("DISPLAY_ORDER"));
        }
    } catch (Exception e) {
        Log.d("YouQi", "Cursor: " + cursor.getString(cursor.getColumnIndex("RAW_JSON")));
        e.printStackTrace();
        Crashlytics.logException(e);
    }
    return entity;
}
 
Example 9
Source File: CrashUtils.java    From IndiaSatelliteWeather with GNU General Public License v2.0 5 votes vote down vote up
public static void trackException(String log, Exception e) {
    if (log != null && !log.isEmpty()) {
        Log.e(log);
        Crashlytics.log(log);
    }
    if (e != null) {
        e.printStackTrace();
        Crashlytics.logException(e);
    }
}
 
Example 10
Source File: AIDLDumper.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
public void next() {
    PlayerServiceAIDL service = getService();
    if (service == null) {
        class Fetcher {}
        pending.add(new RemoteOperation(Fetcher.class.getEnclosingMethod()));
        return;
    }
    try {
        service.next();
    } catch (Exception e) {
        Logger.dExp(e);
        Crashlytics.logException(e);
    }
}
 
Example 11
Source File: FTPNetworkClient.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
/**
 * Return input stream for given file name
 *
 * @param fileName  name of the remote file
 * @param directory remote directory
 * @return input stream or null
 */
public InputStream getInputStream(final String fileName, final String directory) {

    try {
        connectClient();
        changeWorkingDirectory(directory);
        return client.retrieveFileStream(fileName);

    } catch (IOException e) {
        LogUtils.LOGE(TAG, "Error retrieving file from FTP server: " + host, e);
        Crashlytics.logException(e);
    }
    return null;
}
 
Example 12
Source File: FabricTree.java    From android with Apache License 2.0 5 votes vote down vote up
@Override
protected void log(int priority, String tag, String message, Throwable t) {
    if (!Fabric.isInitialized()) return;

    Crashlytics.log(message);

    if (t != null) {
        if (!shouldReport(t)) return;
        Crashlytics.logException(t);
    }
}
 
Example 13
Source File: CrashlyticsLogger.java    From pandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void logAssert(String tag, String msg, Throwable tr) {
    if(initialized) {
        Crashlytics.log(ASSERT, msg, tr != null ? tr.getMessage() : "");
        Crashlytics.logException(tr);
    }
}
 
Example 14
Source File: IslamicLibraryApplication.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void log(int priority, String tag, String message, @Nullable Throwable t) {
    Crashlytics.log(priority, message, tag);
    if (t != null) {
        Crashlytics.logException(t);
    }
    // If this is an error or a warning, log it as a exception so we see it in Crashlytics.
    if (priority >= Log.ERROR) {
        Crashlytics.logException(new Throwable(message));
    }
}
 
Example 15
Source File: NetworkStorageProvider.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public ParcelFileDescriptor openDocument(final String documentId, final String mode,
                                         CancellationSignal signal)
        throws FileNotFoundException {

    final NetworkFile file = getFileForDocId(documentId);
    final NetworkConnection connection = getNetworkConnection(documentId);

    try {
        final boolean isWrite = (mode.indexOf('w') != -1);
        if (isWrite) {
            return null;
        } else {
            Uri ftpUri = connection.toUri(file);
            URL url = new URL(ftpUri.toString());
            URLConnection conn = url.openConnection();
            InputStream inputStream = conn.getInputStream();
            if(null != inputStream){
                return ParcelFileDescriptorUtil.pipeFrom(inputStream);
            }
        }

        return null;
    } catch (Exception e) {
        Crashlytics.logException(e);
        throw new FileNotFoundException("Failed to open document with id " + documentId +
                " and mode " + mode);
    }
}
 
Example 16
Source File: DriveSyncService.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean delete(Photo photo) {
    LogUtil.log(getClass().getSimpleName(), "delete(Photo)");

    SyncInfo info = new SyncInfo();
    info.setTitle(photo.name.toUpperCase());
    info.setSyncService(SyncService.GoogleDrive.ordinal());
    info.setModifiedDate(Calendar.getInstance(Locale.getDefault()).getTimeInMillis());
    info.setSyncStatus(SyncStatus.DELETE);
    SyncInfoDao.saveData(info);

    File file = getPhoto(photo.name);

    if (file != null && file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) {
        try {
            service.files().delete(file.getId()).execute();

            info.setSyncStatus(SyncStatus.OK);
            SyncInfoDao.saveData(info);

            return true;

        } catch (IOException e) {
            // An error occurred.
            e.printStackTrace();
            if (!BuildConfig.DEBUG) Crashlytics.logException(e);
            return false;
        }
    } else {
        LogUtil.log(getClass().getSimpleName(), "file == null: " + (file == null));
        if (!BuildConfig.DEBUG) Crashlytics.log("file == null in DriveSyncService#delete(Photo): " + (file == null));

        info.setSyncStatus(SyncStatus.OK);
        SyncInfoDao.saveData(info);

        return true;
    }
}
 
Example 17
Source File: MainApp.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
@Override protected void log(int priority, String tag, String message, Throwable t) {
  if (priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO) {
    return;
  }

  Crashlytics.setInt(CRASHLYTICS_KEY_PRIORITY, priority);
  Crashlytics.setString(CRASHLYTICS_KEY_TAG, tag);
  Crashlytics.setString(CRASHLYTICS_KEY_MESSAGE, message);

  if (t == null) {
    Crashlytics.logException(new Exception(message));
  } else {
    Crashlytics.logException(t);
  }
}
 
Example 18
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
protected Bitmap doInBackground(Uri... params) {
	if (isCancelled())
		return null;

	final Context context = mIconThumb.getContext();
	final ContentResolver resolver = context.getContentResolver();

	ContentProviderClient client = null;
	Bitmap result = null;
	try {
		if (Utils.isAPK(mMimeType)) {
			result = ((BitmapDrawable) IconUtils.loadPackagePathIcon(context, mPath, Document.MIME_TYPE_APK)).getBitmap();
		} else {
			client = DocumentsApplication.acquireUnstableProviderOrThrow(resolver, mUri.getAuthority());
			result = DocumentsContract.getDocumentThumbnail(resolver, mUri, mThumbSize, mSignal);
		}
		if (null == result){
			result = ImageUtils.getThumbnail(mPath, mMimeType, mThumbSize.x, mThumbSize.y);
		}
		if (result != null) {
			final ThumbnailCache thumbs = DocumentsApplication.getThumbnailsCache(context, mThumbSize);
			thumbs.put(mUri, result);
		}
	} catch (Exception e) {
		if (!(e instanceof OperationCanceledException)) {
			Log.w(TAG, "Failed to load thumbnail for " + mUri + ": " + e);
		}
		Crashlytics.logException(e);
	} finally {
		ContentProviderClientCompat.releaseQuietly(client);
	}
	return result;
}
 
Example 19
Source File: CheckSimpleStoreListener.java    From aptoide-client with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onRequestSuccess(BulkResponse.GetStore response) {

    final Store store = new Store();
    try {
        BulkResponse.GetStore.StoreMetaData data = response.datasets.meta.data;
        store.setId(data.id.longValue());
        store.setName(response.datasets.meta.data.name);
        store.setDownloads(response.datasets.meta.data.downloads.intValue() + "");

        String sizeString = IconSizeUtils.generateSizeStringAvatar(Aptoide.getContext());

        String avatar = data.avatar;

        if (avatar != null) {
            String[] splitUrl = avatar.split("\\.(?=[^\\.]+$)");
            avatar = splitUrl[0] + "_" + sizeString + "." + splitUrl[1];
        }

        store.setAvatar(avatar);
        store.setDescription(data.description);
        store.setTheme(data.theme);
        store.setView(data.view);
        store.setBaseUrl(data.name);

        AptoideDatabase database = new AptoideDatabase(Aptoide.getDb());


        long l = database.insertStore(store);
        database.updateStore(store, l);

        BusProvider.getInstance().post(new OttoEvents.RepoAddedEvent());
        if (callback != null) {
            callback.onSuccess();
        }
    } catch (Exception e) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            String s = mapper.writeValueAsString(response);
            Crashlytics.logException(new Throwable(s, e));
        } catch (JsonProcessingException e1) {
            Logger.printException(e);
        }
    }
}
 
Example 20
Source File: ScriptsFragment.java    From BusyBox with Apache License 2.0 4 votes vote down vote up
private void createScript(String name, String filename) {
  File file = new File(getActivity().getFilesDir(), "scripts/" + filename);
  ShellScript script = new ShellScript(name, file.getAbsolutePath());
  int errorMessage = 0;

  for (ShellScript shellScript : adapter.scripts) {
    if (shellScript.path.equals(script.path) || shellScript.name.equals(script.name)) {
      errorMessage = R.string.a_script_with_that_name_already_exists;
      break;
    }
  }

  try {
    FileUtils.touch(file);
    //noinspection OctalInteger
    Os.chmod(file.getAbsolutePath(), 0755);
  } catch (IOException e) {
    errorMessage = R.string.an_error_occurred_while_creating_the_file;
    Crashlytics.logException(e);
  }

  if (errorMessage != 0) {
    Snackbar snackbar = Snackbar.make(getViewById(R.id.fab), errorMessage, Snackbar.LENGTH_LONG);
    View view = snackbar.getView();
    TextView messageText = (TextView) view.findViewById(R.id.snackbar_text);
    if (getRadiant().isDark()) {
      messageText.setTextColor(getRadiant().primaryTextColor());
      view.setBackgroundColor(getRadiant().backgroundColorDark());
    } else {
      messageText.setTextColor(Color.WHITE);
    }
    snackbar.show();
    return;
  }

  ShellScriptTable table = Database.getInstance().getTable(ShellScriptTable.NAME);
  table.insert(script);
  adapter.scripts.add(script);
  adapter.notifyDataSetChanged();

  Intent intent = new Intent(getActivity(), TextEditorActivity.class);
  intent.putExtra(FileIntents.INTENT_EXTRA_PATH, script.path);
  startActivity(intent);
}