本文整理汇总了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);
}
示例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());
}
示例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);
}