當前位置: 首頁>>代碼示例>>Java>>正文


Java StandardExceptionParser類代碼示例

本文整理匯總了Java中com.google.analytics.tracking.android.StandardExceptionParser的典型用法代碼示例。如果您正苦於以下問題:Java StandardExceptionParser類的具體用法?Java StandardExceptionParser怎麽用?Java StandardExceptionParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StandardExceptionParser類屬於com.google.analytics.tracking.android包,在下文中一共展示了StandardExceptionParser類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupUncaughtExceptionHandler

import com.google.analytics.tracking.android.StandardExceptionParser; //導入依賴的package包/類
/**
 * Report uncaught exceptions (crashes) to Analytics
 */
private void setupUncaughtExceptionHandler() {
    ExceptionReporter myHandler = new ExceptionReporter(EasyTracker.getInstance(this),
            GAServiceManager.getInstance(), Thread.getDefaultUncaughtExceptionHandler(), this);

    StandardExceptionParser exceptionParser =
            new StandardExceptionParser(getApplicationContext(), null) {
                @Override
                public String getDescription(String threadName, Throwable t) {
                    return "{" + threadName + "} " + "{" + Build.MODEL + "} " + "{" + Build.VERSION.SDK_INT + "} " + Log.getStackTraceString(t);
                }
            };

    myHandler.setExceptionParser(exceptionParser);
    Thread.setDefaultUncaughtExceptionHandler(myHandler);
}
 
開發者ID:PhaniGaddipati,項目名稱:Stacks-Flashcards,代碼行數:19,代碼來源:MainActivity.java

示例2: sendNonFatalException

import com.google.analytics.tracking.android.StandardExceptionParser; //導入依賴的package包/類
public static void sendNonFatalException(Context c, Throwable e) {
    EasyTracker.getInstance(c).send(
            MapBuilder.createException(
                    new StandardExceptionParser(c, null)
                            .getDescription(Thread.currentThread().getName(), e),
                    false)    // False indicates a nonfatal exception
                    .build());
}
 
開發者ID:kiwiandroiddev,項目名稱:starcraft-2-build-player,代碼行數:9,代碼來源:EasyTrackerUtils.java

示例3: getAlertMessage

import com.google.analytics.tracking.android.StandardExceptionParser; //導入依賴的package包/類
/**
 * Gets the text message that should be shown or spoken to the user to alert them
 * of an upcoming build item. Handles some minor differences between voice and
 * text messages.
 *
 * @param item
 * @param voice whether the string returned should be displayed or spoken with TTS
 * @return alert message
 */
private String getAlertMessage(BuildItem item, boolean voice) {
    if (!voice && item.getVoice() != null)
        return item.getVoice();

    // if no voice string specified, prefer to use text string
    if (item.getText() != null)
        return item.getText();

    // if neither text nor voice string given, generate a message
    String itemName = mDb.getNameString(item.getGameItemID());

    // e.g. build/train/research
    // TEMPORARY: debugging user device to get more context on a known NPE
    String verb = "";
    try {
        verb = mDb.getVerbForItem(item.getGameItemID());
    } catch (Exception e) {
        // Report this error for analysis
        String err = "getVerbForItem() in getAlertMessage() threw exception " + e.getMessage() +
                " for item " + item + " in build " + mBuild + " playback time=" +
                mTimerText.getText().toString();

        EasyTracker.getInstance(this).send(
                MapBuilder.createException(
                        new StandardExceptionParser(this, null)
                                .getDescription(Thread.currentThread().getName(), e),
                        false)    // False indicates a nonfatal exception
                        .build());

        return itemName;    // compromise to prevent crash: just say item name
    }

    Map<String, String> args = new HashMap<>();
    args.put("item", itemName);
    args.put("verb", verb);
    args.put("count", "" + item.getCount() + (!voice ? "x" : ""));
    args.put("target", mDb.getNameString(item.getTarget()));

    String template;
    ItemType itemType = mDb.getItemType(item.getGameItemID());
    final boolean multipleItems = item.getCount() > 1;
    if (itemType == ItemType.STRUCTURE) {
        if (item.getTarget() == null)
            template = getString(multipleItems ? R.string.sentence_structure_plural_no_target : R.string.sentence_structure_singular_no_target);
        else
            template = getString(multipleItems ? R.string.sentence_structure_plural_with_target : R.string.sentence_structure_singular_with_target);
    } else if (itemType == ItemType.ABILITY) {
        if (item.getTarget() == null)
            template = getString(R.string.sentence_ability_no_target);
        else
            template = getString(R.string.sentence_ability_with_target);
    } else if (itemType == ItemType.UPGRADE) {
        template = getString(R.string.sentence_upgrade);
    } else if (itemType == ItemType.UNIT) {
        template = getString(multipleItems ? R.string.sentence_unit_plural : R.string.sentence_unit_singular);
    } else {
        // probably a NOTE with no text message, fallback to item name
        return itemName;
    }

    return MapFormat.format(template, args);
}
 
開發者ID:kiwiandroiddev,項目名稱:starcraft-2-build-player,代碼行數:72,代碼來源:PlaybackActivity.java


注:本文中的com.google.analytics.tracking.android.StandardExceptionParser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。