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

The following examples show how to use com.crashlytics.android.Crashlytics#setString() . 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: ActivityGlobalAbstract.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    if (!getResources().getBoolean(R.bool.is_tablet))
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);

    if (!BuildConfig.DEBUG && !BuildConfig.BUILD_TYPE.equals("beta"))
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
    SharedPreferences prefs = getSharedPreferences();
    if (this instanceof MainActivity || this instanceof LoginActivity || this instanceof SplashActivity) {
        prefs.edit().remove(Constants.PROGRAM_THEME).apply();
    }

    if (!(this instanceof SplashActivity) && !(this instanceof LoginActivity))
        setTheme(prefs.getInt(Constants.PROGRAM_THEME, prefs.getInt(Constants.THEME, R.style.AppTheme)));

    Crashlytics.setString(Constants.SERVER, prefs.getString(Constants.SERVER, null));
    String userName = prefs.getString(Constants.USER, null);
    if (userName != null)
        Crashlytics.setString(Constants.USER, userName);
    mFirebaseAnalytics.setUserId(prefs.getString(Constants.SERVER, null));

    super.onCreate(savedInstanceState);
}
 
Example 2
Source File: MAPDownloadController.java    From IndiaSatelliteWeather with GNU General Public License v2.0 6 votes vote down vote up
private Bitmap removeMapBorders(String mapFileName, Bitmap bmp) {
    //Try to remove unwanted parts from MAP. return the original MAP in case of any errors.
    try {
        //Trim the unwanted area from the Ultra Violet Map.
        if (mapFileName.equals(AppConstants.MAP_UV) || mapFileName.equals(AppConstants.MAP_HEAT)) {
            return Bitmap.createBitmap(bmp, 0, 180, 1250, 1400);
        }
    } catch (Exception e) {
        Crashlytics.log("trim MAP Error");
        Crashlytics.setString("MapType", mapFileName);
        try {
            if (bmp != null) {
                Crashlytics.setInt("mapWidth", bmp.getWidth());
                Crashlytics.setInt("mapHeight", bmp.getHeight());
            }
        } catch (Exception e1) {
            Crashlytics.logException(e1);
        }
        Crashlytics.logException(e);
    }
    return bmp;
}
 
Example 3
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 4
Source File: BonjourApplication.java    From BonjourBrowser with Apache License 2.0 5 votes vote down vote up
private Rx2Dnssd createDnssd() {
    Crashlytics.setString(DEVICE, Build.BRAND + " " + Build.MODEL);
    Crashlytics.setString(ARCH, System.getProperty("os.arch"));

    Log.i(TAG, "Using embedded version of dns sd");
    Crashlytics.setString(DNSSD, "Using embedded version of dns sd");
    return new Rx2DnssdEmbedded(this);
}
 
Example 5
Source File: MultiObjectAdapter.java    From Contacts with MIT License 5 votes vote down vote up
@Override
protected TypeAdapter<BaseType> getAdapter(BaseType object, int layoutType)
{
	TypeAdapter<BaseType> adapter = AdapterSelector.getAdapter(object, layoutType, this);

	if (adapter == null)
	{
		Crashlytics.setString("MultiObjectAdapter_object", object != null ? object.toString() : "object is null");
		Crashlytics.setString("MultiObjectAdapter_layout", String.valueOf(layoutType));
	}

	return adapter;
}
 
Example 6
Source File: MultiObjectAdapter.java    From Klyph with MIT License 5 votes vote down vote up
@Override
protected TypeAdapter<GraphObject> getAdapter(GraphObject object, int layoutType)
{
	TypeAdapter<GraphObject> adapter = AdapterSelector.getAdapter(object, layoutType, this);

	if (adapter == null)
	{
		Crashlytics.setString("MultiObjectAdapter_object", object != null ? object.toString() : "object is null");
		Crashlytics.setString("MultiObjectAdapter_layout", String.valueOf(layoutType));
	}

	return adapter;
}
 
Example 7
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 8
Source File: SetStringFunction.java    From ANE-Crashlytics with Apache License 2.0 5 votes vote down vote up
public FREObject call(FREContext context, FREObject[] args) {
	super.call(context, args);
	
	String key = getStringFromFREObject(args[0]);
	String value = getStringFromFREObject(args[1]);
	Crashlytics.setString(key, value);
	
	return null;
}
 
Example 9
Source File: CrashReport.java    From rebootmenu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 开始错误报告
 * 逻辑:如果自动上传配置为假,自动捕捉,否则不做处理(由Crashlytics捕捉)
 *
 * @param context {@link Context}
 * @param handler {@link java.lang.Thread.UncaughtExceptionHandler}
 */
public static void start(Context context, Thread.UncaughtExceptionHandler handler) {
    long launchTimes = ConfigManager.getPrivateLong(context, ConfigManager.APP_LAUNCH_TIMES, 0);
    /*
     * 第一条件:用户不是一般用户 -> !(安装了酷安,是MIUI系统)
     * 第二条件:自动上报功能关闭,或条件不足以加载csc
     */
    if (!CoolapkCompat.hasCoolapk(context) && !SpecialSupport.isMIUI()) {
        if (!ConfigManager.getPrivateBoolean(context, ConfigManager.AUTO_CRASH_REPORT, false) || !MainCompat.shouldLoadCSC())
            Thread.setDefaultUncaughtExceptionHandler(handler);
    } else {
        //Firebase Crashlytics抓取的机型信息不全面,这里再手动抓一次
        try {
            JSONObject object = new JSONObject(SendBugFeedback.getRawBuildEnvInfo());
            Iterator iterator = object.keys();
            while (iterator.hasNext()) {
                String key = (String) iterator.next();
                Crashlytics.setString(key, object.getString(key));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Crashlytics.setLong("launchTimes", launchTimes);
        //小米设备的话看看是不是原版系统
        if ("Xiaomi".equals(Build.MANUFACTURER))
            Crashlytics.setBool("isMIUI", SpecialSupport.isMIUI());
        Crashlytics.setString("serviceAvailableState", GmsApiWrapper.fetchStateString(context));
    }
    ConfigManager.setPrivateLong(context, ConfigManager.APP_LAUNCH_TIMES, ++launchTimes);
}
 
Example 10
Source File: Aptoide.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Analytics.Lifecycle.Application.onCreate(this);

    setAdvertisingIdClient();

    context = this;
    db = SQLiteDatabaseHelper.getInstance(this).getReadableDatabase();
    filters = AptoideUtils.HWSpecifications.filters(this);

    ManagerPreferences.getInstance(this) //inits the ManagerPreferences
            .preferences
            .registerOnSharedPreferenceChangeListener(
                    listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
                        @Override
                        public void onSharedPreferenceChanged(
                                final SharedPreferences sharedPreferences, final String key) {
                            if (TextUtils.equals(key, "hwspecsChkBox")) {
                                filters = AptoideUtils.HWSpecifications.filters(Aptoide.this);
                            }
                        }
                    });


    Crashlytics crashlyticsKit = new Crashlytics.Builder()
            .core(new CrashlyticsCore.Builder().disabled(!BuildConfig.FABRIC_CONFIGURED).build())
            .build();
    Fabric.with(this, crashlyticsKit);

    setConfiguration(getAptoideConfiguration());
    initImageLoader();
    setDebugMode();
    checkIsSystem();
    setThemePicker(getNewThemePicker());
    Crashlytics.setString("Language", getResources().getConfiguration().locale.getLanguage());
    AptoideUtils.CrashlyticsUtils.subsctibeActivityLiveCycleEvent();
}
 
Example 11
Source File: AptoideUtils.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
/**
 * this method adds a screen name to the history to be reported to crashlytics
 * @param screeName screen name that should be reported to crashlytics
 */
public static void addScreenToHistory (String screeName) {
    if (BuildConfig.FABRIC_CONFIGURED) {
        addScreen(screeName);
        Crashlytics.setString(SCREEN_HISTORY, history.toString());
    }
}
 
Example 12
Source File: AptoideUtils.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public static String screenshotToThumb(Context context, String imageUrl, String orientation) {

            String screen = null;

            try {

                if (imageUrl.contains("_screen")) {

                    String sizeString = IconSizeUtils.generateSizeStringScreenshots(context, orientation);

                    String[] splitUrl = imageUrl.split("\\.(?=[^\\.]+$)");
                    screen = splitUrl[0] + "_" + sizeString + "." + splitUrl[1];

                } else {

                    String[] splitString = imageUrl.split("/");
                    StringBuilder db = new StringBuilder();
                    for (int i = 0; i != splitString.length - 1; i++) {
                        db.append(splitString[i]);
                        db.append("/");
                    }

                    db.append("thumbs/mobile/");
                    db.append(splitString[splitString.length - 1]);
                    screen = db.toString();
                }

            } catch (Exception e) {
                Logger.printException(e);
                Crashlytics.setString("imageUrl", imageUrl);
                Crashlytics.logException(e);
            }

            return screen;
        }
 
Example 13
Source File: DemoApplication.java    From TubiPlayer with MIT License 5 votes vote down vote up
public static void initFabric(@NonNull Context context) {
    final Fabric.Builder fabric = new Fabric.Builder(context)
            .kits(new Crashlytics(), new Answers());
    fabric.debuggable(true);
    Fabric.with(fabric.build());

    Crashlytics.setString("com.crashlytics.android.build_id", UUID.randomUUID().toString());
}
 
Example 14
Source File: JSONUtility.java    From Kernel-Tuner with GNU General Public License v3.0 5 votes vote down vote up
public JSONUtility(String stringObject)
{
    this.serverResponse = new Internet.Response();
    serverResponse.code = 200;
    serverResponse.request = null;
    serverResponse.responseData = stringObject;
    serverResponse.responseMessage = null;
    if (serverResponse.isResponseOk())
    {
        try
        {
            fixResponse();
            jsonObject = new JSONObject(this.serverResponse.responseData);
            checkErrors();
        }
        catch (Exception e)
        {
            if (PrefsManager.DEBUG()) Log.e(Constants.LOG_TAG, "JSONUtility " + e.getMessage());
            if (PrefsManager.DEBUG())
                Log.e(Constants.LOG_TAG, "JSONUtility :: Failed to parse json");
            Crashlytics.setString("response message", serverResponse.responseMessage);
            Crashlytics.setString("response data", serverResponse.responseData);
            Crashlytics.setInt("response code", serverResponse.code);
            Crashlytics.setString("request url", serverResponse.request);
            Crashlytics.logException(e);
        }
    }
}
 
Example 15
Source File: CrashlyticsLogger.java    From pandroid with Apache License 2.0 4 votes vote down vote up
@Override
public void addKey(String key, String value) {
    if(initialized) {
        Crashlytics.setString(key, value);
    }
}
 
Example 16
Source File: PoemBuilderActivity.java    From cannonball-android with Apache License 2.0 4 votes vote down vote up
private void createPoem() {
    if (poemContainer.getChildCount() > 0) {
        final String poemText = getPoemText();
        final int poemImage = getPoemImageId();

        Crashlytics.setString(App.CRASHLYTICS_KEY_POEM_TEXT, poemText);
        Crashlytics.setInt(App.CRASHLYTICS_KEY_POEM_IMAGE, poemImage);

        long creationTimeStamp = System.currentTimeMillis() / 1000L;

        Poem newPoem = new Poem(poemText, poemImage, poemTheme.getDisplayName(), creationTimeStamp);
        FirebaseHelpers.savePoem(newPoem).addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Toast.makeText(getApplicationContext(),
                            "Poem saved!", Toast.LENGTH_SHORT)
                            .show();
                } else {
                    Toast.makeText(getApplicationContext(),
                            "Problem saving poem", Toast.LENGTH_SHORT)
                            .show();
                }
            }
        });

        Bundle bundle  = new Bundle();
        bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, poemTheme.getDisplayName());
        bundle.putInt("length", poemContainer.getChildCount());
        // this disagrees with cannonball-iOS, since cannonball-iOS saves a full file name
        bundle.putString("picture", getPoemImageId() + "");
        mFirebaseAnalytics.logEvent("save_poem", bundle);

        final Intent i = new Intent(getApplicationContext(), PoemHistoryActivity.class);
        i.putExtra(ThemeChooserActivity.IS_NEW_POEM, true);
        startActivity(i);
    } 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");
    }
}
 
Example 17
Source File: BaseFragment.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    Crashlytics.setString("last_foreground_fragment", getClass().getName());
}
 
Example 18
Source File: HotFragment.java    From 1Rramp-Android with MIT License 4 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Crashlytics.setString(CrashReporterKeys.UI_ACTION, "hot fragment");
  setRetainInstance(true);
}
 
Example 19
Source File: TrendingFragment.java    From 1Rramp-Android with MIT License 4 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Crashlytics.setString(CrashReporterKeys.UI_ACTION, "trending fragment");
  setRetainInstance(true);
}
 
Example 20
Source File: ActivityGlobalAbstract.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void setScreenName(String name) {
    Crashlytics.setString(Constants.SCREEN_NAME, name);
}