下面列出了java.io.SyncFailedException#com.crashlytics.android.Crashlytics 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onCreate() {
super.onCreate();
mContext = this.getApplicationContext();
initNotificationChannels();
if (!BuildConfig.DEBUG) {
try {
Fabric.with(this, new Crashlytics());
final Fabric fabric = new Fabric.Builder(this)
.kits(new Crashlytics())
.debuggable(true)
.build();
Fabric.with(fabric);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void clearApplicationCache(Context context, File file) {
File dir = null;
if (file == null) {
dir = context.getCacheDir();
} else {
dir = file;
}
if (dir == null) return;
File[] children = dir.listFiles();
try {
for (File child : children)
if (child.isDirectory()) clearApplicationCache(context, child);
else child.delete();
} catch (Exception e) {
Crashlytics.logException(e);
}
}
@Override
public void onCreate() {
super.onCreate();
Crashlytics.start(this);
// Do init here
FlowAsyncClient.init(getApplicationContext());
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisc(true)
.displayer(new FadeInBitmapDisplayer(500))
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.defaultDisplayImageOptions(defaultOptions)
.build();
ImageLoader.getInstance().init(config);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
if (preferences != null) {
mIsUserLoggedIn = preferences.getBoolean(IS_USER_LOGGED_IN_KEY, false);
}
getMixpanel();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_login_registration);
login = (Button) findViewById(R.id.btn_login);
register = (Button) findViewById(R.id.btn_register);
cardView=(CardView)findViewById(R.id.layout2);
splashActivity=new SplashActivity();
login.setOnClickListener(this);
register.setOnClickListener(this);
b=splashActivity.containsPass("password");
if(b==true)
{
register.setVisibility(View.INVISIBLE);
cardView.setVisibility(View.INVISIBLE);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_registration);
auth = FirebaseAuth.getInstance();
appStatus=new AppStatus(getApplicationContext());
register = (Button) findViewById(R.id.btn_register);
existinguser = (Button) findViewById(R.id.existinguser);
edt_Password = (EditText) findViewById(R.id.edt_Rpassword);
edt_RePassword = (EditText) findViewById(R.id.edt_RRepassword);
edt_Email = (EditText) findViewById(R.id.edt_email);
progressBar=(ProgressBar)findViewById(R.id.progressBar);
register.setOnClickListener(this);
existinguser.setOnClickListener(this);
}
@Override
protected Long doInBackground(Uri... params) {
if (isCancelled())
return null;
Long result = null;
try {
if (!TextUtils.isEmpty(mPath)) {
File dir = new File(mPath);
result = Utils.getDirectorySize(dir);
}
} catch (Exception e) {
if (!(e instanceof OperationCanceledException)) {
Log.w(TAG, "Failed to calculate size for " + mPath + ": " + e);
}
Crashlytics.logException(e);
}
return result;
}
@Override
public void onCreate() {
super.onCreate();
appComponent = DaggerAppComponent.builder()
.appModule(new AppModule(JianShiApplication.this))
.build();
final Fabric fabric = new Fabric.Builder(this)
.kits(new Crashlytics())
.debuggable(true)
.build();
Fabric.with(fabric);
Stetho.initializeWithDefaults(this);
instance = this;
FlowManager.init(new FlowConfig.Builder(this).openDatabasesOnInit(true).build());
initLog();
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/jianshi_default.otf")
.setFontAttrId(R.attr.fontPath)
.build()
);
}
@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;
}
public static boolean copy(InputStream inputStream, OutputStream outputStream){
boolean successful = false;
try {
IoUtils.copy(inputStream, outputStream);
outputStream.flush();
successful = true;
} catch (IOException e) {
Log.e("TransferThread", "writing failed");
Crashlytics.logException(e);
} finally {
IoUtils.closeQuietly(inputStream);
IoUtils.closeQuietly(outputStream);
}
return successful;
}
private void setSteemEarnings(CommentModel commentModel) {
try {
double pendingPayoutValue = Double.parseDouble(commentModel.getPendingPayoutValue().split(" ")[0]);
double totalPayoutValue = Double.parseDouble(commentModel.getTotalPayoutValue().split(" ")[0]);
double curatorPayoutValue = Double.parseDouble(commentModel.getCuratorPayoutValue().split(" ")[0]);
String briefPayoutValueString;
if (pendingPayoutValue > 0) {
briefPayoutValueString = String.format(Locale.US, "%1$.3f", pendingPayoutValue);
} else {
//cashed out
briefPayoutValueString = String.format(Locale.US, "%1$.3f", totalPayoutValue + curatorPayoutValue);
}
payoutValue.setText(briefPayoutValueString);
}
catch (Exception e) {
Crashlytics.log(e.toString());
}
}
private void getName(){
Uri uri = getIntent().getData();
if(null == uri){
return;
}
String name = "";
String scheme = uri.getScheme();
if (!TextUtils.isEmpty(scheme) && scheme.startsWith(ContentResolver.SCHEME_CONTENT)) {
String part = uri.getSchemeSpecificPart();
final int splitIndex = part.indexOf(':', 1);
if(splitIndex != -1) {
name = part.substring(splitIndex + 1);
}
if(TextUtils.isEmpty(name)){
name = uri.getLastPathSegment();
}
}
else if (!TextUtils.isEmpty(scheme) && scheme.startsWith(ContentResolver.SCHEME_FILE)) {
name = uri.getLastPathSegment();
} else {
Crashlytics.log(Log.ERROR, "Error", "URI Error"); //incomplete
}
getSupportActionBar().setTitle(FileUtils.getName(name));
getSupportActionBar().setSubtitle("");
}
@SuppressWarnings("unchecked")
@Override
protected void dispatchDraw(Canvas canvas) {
try {
Field field = ViewGroup.class.getDeclaredField("mDisappearingChildren");
field.setAccessible(true);
mDisappearingChildren = (ArrayList<View>) field.get(this);
} catch (Exception e) {
Crashlytics.logException(e);
}
final ArrayList<View> disappearing = mDisappearingChildren;
if (mDisappearingFirst && disappearing != null) {
for (int i = 0; i < disappearing.size(); i++) {
super.drawChild(canvas, disappearing.get(i), getDrawingTime());
}
}
super.dispatchDraw(canvas);
}
private void createPoem() {
if (poemContainer.getChildCount() > 0) {
final String poemText = getPoemText();
final SparseIntArray imgList = poemTheme.getImageList();
// the line below seems weird, but relies on the fact that the index of SparseIntArray could be any integer
final int poemImage = imgList.keyAt(imgList.indexOfValue(imgList.get(poemImagePager.getCurrentItem() + 1)));
Crashlytics.setString(App.CRASHLYTICS_KEY_POEM_TEXT, poemText);
Crashlytics.setInt(App.CRASHLYTICS_KEY_POEM_IMAGE, poemImage);
Answers.getInstance().logCustom(new CustomEvent("clicked save poem")
.putCustomAttribute("poem size", poemText.length())
.putCustomAttribute("poem theme", poemTheme.getDisplayName())
.putCustomAttribute("poem image", poemImage));
AppService.createPoem(getApplicationContext(),
poemText,
poemImage,
poemTheme.getDisplayName(),
dateFormat.format(Calendar.getInstance().getTime()));
} else {
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.toast_wordless_poem), Toast.LENGTH_SHORT)
.show();
Crashlytics.log("PoemBuilder: User tried to create poem without words on it");
}
}
private void showAppList() {
AppListAdapter adapter = new AppListAdapter(this);
List<RootAppInfo> crossPromoAppInfos = null;
try {
crossPromoAppInfos = getFeaturedRootApps();
} catch (Exception e) {
Crashlytics.logException(e);
}
if (crossPromoAppInfos == null) {
crossPromoAppInfos = new ArrayList<>();
}
adapter.setAppInfos(crossPromoAppInfos);
ObservableGridView gridView = (ObservableGridView) getViewById(R.id.list);
gridView.setAdapter(adapter);
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_recording);
tabHost = (FragmentTabHost)findViewById(R.id.tabhost);
tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
this.addTab(ReadingFragment.class, getString(R.string.title_text));
this.addTab(RecordGraphFragment.class, getString(R.string.realtime_graph));
SharedPreferences sharedPref =
getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
Integer tabIndex = sharedPref.getInt(getString(R.string.recording_tab_index), 0);
tabHost.setCurrentTab(tabIndex);
}
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
mInstance = this;
MultiDex.install(this);
Colorful.init(this);
/*
* Enable stetho only in debug mode. */
if (BuildConfig.DEBUG) {
Stetho.initializeWithDefaults(this);
}
AlarmsManager.init(getApplicationContext());
WakeLockManager.init(getApplicationContext(), false);
}
@NonNull
public static String formatDate(@NonNull HijriDate date) {
String format = getDateFormat(true);
format = format.replace("DD", az(date.getDay(), 2));
if (format.contains("MMM")) {
try {
format = format.replace("MMM", getHijriMonth(date.getMonth() - 1));
} catch (ArrayIndexOutOfBoundsException ex) {
Crashlytics.logException(ex);
return "";
}
}
format = format.replace("MM", az(date.getMonth(), 2));
format = format.replace("YYYY", az(date.getYear(), 4));
format = format.replace("YY", az(date.getYear(), 2));
return formatNumber(format);
}
@Override public void onCreate() {
super.onCreate();
MultiDex.install(this);
// Logging
if (BuildConfig.DEBUG) {
Jot.add(new Jot.DebugLogger());
} else {
Jot.add(new CrashlyticsLogger());
}
// Fabric
Fabric.with(this, new Crashlytics(), new Answers());
Analytics.add(AnswersLogger.getInstance());
// Crashlytics
Crashlytics.setString("GIT_SHA", BuildConfig.GIT_SHA);
Crashlytics.setString("BUILD_TIME", BuildConfig.BUILD_TIME);
FirebaseMessaging.getInstance().subscribeToTopic("main-" + BuildConfig.FLAVOR);
}
public void play(final SongBean song, final int index) {
final PlayerServiceAIDL service = getService();
if (service == null) {
class Fetcher {}
pending.add(new RemoteOperation(Fetcher.class.getEnclosingMethod(), song, index));
return;
}
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
try {
service.play(song, index);
} catch (Exception e) {
Logger.dExp(e);
Crashlytics.logException(e);
}
}
});
}
public void updateSelectionWithNewAssets(Map<String, Object> map){
Crashlytics.log(Log.INFO, LOG_TAG, "Received map - "+map);
Map<String, List<String>> selected = getUserFeedMapFromJsonMap(map);
Crashlytics.log(Log.INFO, LOG_TAG, "New selected - "+selected);
for (String newspaper : selected.keySet()) {
List<String> categories;
if (userSelectionMap.containsKey(newspaper)) {
categories = userSelectionMap.get(newspaper);
categories.addAll(selected.get(newspaper));
} else {
categories = selected.get(newspaper);
}
userSelectionMap.put(newspaper, categories);
Crashlytics.log(Log.INFO, LOG_TAG, "New selection for "+newspaper+ " is "+categories);
}
Crashlytics.log(Log.INFO, LOG_TAG, "newUserSelectionMap - "+userSelectionMap);
setUserPrefChanged(true);
convertUserFeedMapToJsonMap();
}
@Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(this);
Parse.initialize(this, Constants.getConstant(this, R.string.PARSE_APP_ID),
Constants.getConstant(this, R.string.PARSE_CLIENT_KEY));
Fabric.with(this, new Crashlytics());
Crashlytics.getInstance().setDebugMode(false);
Crashlytics.log(Log.INFO, StarterApplication.class.getName(), "Starting Application - " + System.currentTimeMillis());
NewsCatFileUtil.getInstance(this);
UserPrefUtil.getInstance(this);
ParseConfig.getInBackground(new ConfigCallback() {
@Override
public void done(ParseConfig config, ParseException e) {
ConfigService.getInstance();
ConfigService.getInstance().setInstance(StarterApplication.this);
}
});
}
public static List<TimeSpan> getActiveProfile(String profile, SharedPreferences prefs){
Integer activeProfileIndex=-1;
List<TimeSpan> activeProfile;
String profileRawString = prefs.getString(profile, "");
if (profileRawString.equals("")){
//We do not have any profiles, return an empty one
activeProfile = newEmptyProfile();
} else {
ArrayList<ArrayList> profileDetailsArray = new Gson().fromJson(profileRawString,new TypeToken<List<ArrayList>>() {}.getType() );
for(int index = 0; index < profileDetailsArray.size(); index++){
if (profileDetailsArray.get(index).get(1).equals("active")) activeProfileIndex = index;
}
if (activeProfileIndex.equals(-1)){
//Could not find the profile, return an empty one
activeProfile = newEmptyProfile();
Crashlytics.log(1,TAG,"Could not find the profile, return an empty one " + profile);
} else {
activeProfile = getProfile(profile, activeProfileIndex, prefs);
}
}
return activeProfile;
}
private boolean onUninstallApp(DocumentInfo doc) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
boolean hadTrouble = false;
if (!doc.isDeleteSupported()) {
Log.w(TAG, "Skipping " + doc);
hadTrouble = true;
return hadTrouble;
}
try {
DocumentsContract.deleteDocument(resolver, doc.derivedUri);
} catch (Exception e) {
Log.w(TAG, "Failed to delete " + doc);
Crashlytics.logException(e);
hadTrouble = true;
}
return hadTrouble;
}
private BookmarkModel getBookmarkModelObject() {
final BookmarkModel bookmarkModel = new BookmarkModel();
try {
bookmarkModel.setmArticleHeadline(mArticleHeadline);
bookmarkModel.setCategoryName(catNameString);
bookmarkModel.setNewspaperName(npNameString);
bookmarkModel.setmArticleURL(mArticleURL);
bookmarkModel.setmArticleBody(mArticleBody);
bookmarkModel.setmArticleImageURL(mArticleImageURL);
bookmarkModel.setmArticlePubDate(mArticlePubDate);
} catch (Exception e) {
Crashlytics.log("Exception while creating bookmark object - " + e.getMessage());
Crashlytics.logException(e);
}
return bookmarkModel;
}
private static String hashKeyForPIN(String value) {
if (TextUtils.isEmpty(value))
return null;
try {
//MessageDigest digester = MessageDigest.getInstance("MD5");
//return Base64.encodeToString(value.getBytes(), Base64.DEFAULT);
}
catch (Exception e) {
Crashlytics.logException(e);
}
return value;
}
public static JSONObject iobCalc(Bolus bolus, Date time, Double dia) {
JSONObject returnValue = new JSONObject();
Double diaratio = 3.0 / dia;
Double peak = 75D ;
Double end = 180D ;
//if (treatment.type.equals("Insulin") ) { //Im only ever passing Insulin
Date bolusTime = bolus.getTimestamp(); //Time the Insulin was taken
Double minAgo = diaratio * (time.getTime() - bolusTime.getTime()) /1000/60; //Age in Mins of the treatment
Double iobContrib = 0D;
Double activityContrib = 0D;
if (minAgo < peak) { //Still before the Peak stage of the insulin taken
Double x = (minAgo/5 + 1);
iobContrib = bolus.getValue() * (1 - 0.001852 * x * x + 0.001852 * x); //Amount of Insulin active? // TODO: 28/08/2015 getting negative numbers at times, what is this doing?
//var activityContrib=sens*treatment.insulin*(2/dia/60/peak)*minAgo;
activityContrib=bolus.getValue() * (2 / dia / 60 / peak) * minAgo;
}
else if (minAgo < end) {
Double y = (minAgo-peak)/5;
iobContrib = bolus.getValue() * (0.001323 * y * y - .054233 * y + .55556);
//var activityContrib=sens*treatment.insulin*(2/dia/60-(minAgo-peak)*2/dia/60/(60*dia-peak));
activityContrib=bolus.getValue() * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * dia - peak));
}
try {
returnValue.put("iobContrib", iobContrib);
if (activityContrib.isInfinite()) activityContrib = 0D; //*HAPP added*
returnValue.put("activityContrib", activityContrib);
} catch (JSONException e) {
Crashlytics.logException(e);
e.printStackTrace();
}
return returnValue;
//}
}
@Override
public void onCreate() {
super.onCreate();
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(mCaughtExceptionHandler);
//handle CameraView crash and still report to crashlytics
CrashlyticsCore core = new CrashlyticsCore.Builder()
//.disabled(BuildConfig.DEBUG)
.build();
Fabric.with(new Fabric.Builder(this).kits(new Crashlytics.Builder()
.core(core)
.build())
.initializationCallback(new InitializationCallback<Fabric>() {
@Override
public void success(Fabric fabric) {
//Thread.setDefaultUncaughtExceptionHandler(mCaughtExceptionHandler);
if(mDefaultUEH != Thread.getDefaultUncaughtExceptionHandler()){
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(mCaughtExceptionHandler);
}
}
@Override
public void failure(Exception e) {
}
})
.build());
}
@Override
protected String[] doInBackground(Void... params) {
try {
articleContent[0] = mArticleHeadline;
articleContent[1] = mArticleImageURL;
articleContent[2] = mArticleBody;
} catch (Exception e) {
Crashlytics.log("Exception while reading bookmarks- " + e.getMessage());
Crashlytics.logException(e);
}
return articleContent;
}
@Subscribe
public void onCreatePostEvent(final CreatePostEvent event) {
Crashlytics.log(Log.DEBUG, TAG, "[onCreatePostEvent] creating new post");
Post newPost = new Post();
newPost.addPendingAction(PendingAction.CREATE);
newPost.setId(getTempUniqueId(Post.class));
createOrUpdateModel(newPost); // save the local post to db
getBus().post(new PostCreatedEvent(newPost));
getBus().post(new SyncPostsEvent(false));
}
@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;
}