本文整理了Java中com.segment.analytics.Analytics.with()
方法的一些代码示例,展示了Analytics.with()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Analytics.with()
方法的具体详情如下:
包路径:com.segment.analytics.Analytics
类名称:Analytics
方法名:with
[英]Return a reference to the global default Analytics instance.
This instance is automatically initialized with defaults that are suitable to most implementations.
If these settings do not meet the requirements of your application, you can override defaults in analytics.xml, or you can construct your own instance with full control over the configuration by using Builder.
By default, events are uploaded every 30 seconds, or every 20 events (whichever occurs first), and debugging is disabled.
[中]返回对全局默认分析实例的引用。
此实例使用适用于大多数实现的默认值自动初始化。
如果这些设置不符合应用程序的要求,则可以覆盖分析中的默认设置。xml,或者您可以使用Builder构建自己的实例,完全控制配置。
默认情况下,每30秒或每20个事件(以先发生的为准)上载一次事件,并禁用调试。
代码示例来源:origin: segmentio/analytics-android
public Analytics getAnalytics() {
return Analytics.with(this);
}
}
代码示例来源:origin: segmentio/analytics-android
@OnClick(R.id.action_track_b)
void onButtonBClicked() {
Analytics.with(this).track("Button B Clicked");
}
代码示例来源:origin: segmentio/analytics-android
@OnClick(R.id.action_flush)
void onFlushButtonClicked() {
Analytics.with(this).flush();
}
代码示例来源:origin: segmentio/analytics-android
@OnClick(R.id.action_track_a)
void onButtonAClicked() {
Analytics.with(this).track("Button A Clicked");
}
代码示例来源:origin: segmentio/analytics-android
@OnClick(R.id.action_identify)
void onIdentifyButtonClicked() {
String id = userId.getText().toString();
if (isNullOrEmpty(id)) {
Toast.makeText(this, R.string.id_required, Toast.LENGTH_LONG).show();
} else {
Analytics.with(this).identify(id);
}
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void invalidWriteKeyFromResourcesThrowsException() throws Exception {
mockWriteKeyInResources(context, null);
try {
Analytics.with(context);
fail("Null writeKey should throw exception.");
} catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("writeKey must not be null or empty.");
}
mockWriteKeyInResources(context, "");
try {
Analytics.with(context);
fail("Empty writeKey should throw exception.");
} catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("writeKey must not be null or empty.");
}
mockWriteKeyInResources(context, " ");
try {
Analytics.with(context);
fail("blank writeKey should throw exception.");
} catch (IllegalArgumentException expected) {
assertThat(expected).hasMessage("writeKey must not be null or empty.");
}
}
代码示例来源:origin: segmentio/analytics-android
@Test
public void setSingleInstanceReturnedFromWith() {
Analytics.singleton = null;
Analytics analytics = new Analytics.Builder(RuntimeEnvironment.application, "foo").build();
Analytics.setSingletonInstance(analytics);
assertThat(Analytics.with(RuntimeEnvironment.application)).isSameAs(analytics);
}
代码示例来源:origin: segmentio/analytics-android
Analytics analytics = Analytics.with(this);
内容来源于网络,如有侵权,请联系作者删除!