本文整理汇总了Java中com.google.android.gms.analytics.Tracker类的典型用法代码示例。如果您正苦于以下问题:Java Tracker类的具体用法?Java Tracker怎么用?Java Tracker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tracker类属于com.google.android.gms.analytics包,在下文中一共展示了Tracker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onViewCreated
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
listView = (RecyclerView)view.findViewById(android.R.id.list);
listView.setLayoutManager(new LinearLayoutManager(getActivity()));
listView.setItemAnimator(new DefaultItemAnimator());
listView.setAdapter(adapter);
view.findViewById(R.id.fabNewPlaylist).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
newPlaylist();
}
});
Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER);
t.setScreenName("List of playlists");
t.send(new HitBuilders.AppViewBuilder().build());
}
示例2: init
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
public void init(BaseActivity activity){
baseActivity = activity;
activityStack.push(activity);
sh = new SharedHelper(activity.getApplicationContext());
loadingDialog = new LoadingDialog(activity);
loadingDialog.setOnCancelListener((dialogInterface -> canceled = true));
String screenName = activity.getClass().getSimpleName();
activityMap.put(screenName + System.currentTimeMillis(), activity);
if (SStaticR.ANALYTICS_ON){
// Obtain the shared Tracker instance.
LIVE application = (LIVE)baseActivity.getApplication();
Tracker mTracker = application.getDefaultTracker();
mTracker.setScreenName(screenName);
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
}
示例3: onCreateView
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_podcast, container, false);
mActivity = (Home) getActivity();
mContext = getContext();
podcastList = (ListView) v.findViewById(R.id.podcastlist);
noElements = (TextView) v.findViewById(R.id.no_elements);
avi = (AVLoadingIndicatorView) v.findViewById(R.id.avi);
avi.show();
// Get Programs
new GetPrograms(mContext, this).execute();
App application = (App) getActivity().getApplication();
Tracker mTracker = application.getDefaultTracker();
mTracker.setScreenName(getString(R.string.podcast_view));
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
return v;
}
示例4: onCreateView
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_transmissions, container, false);
mActivity = (Home) getActivity();
mContext = getContext();
transmissionList = (ListView) v.findViewById(R.id.transmissionsList);
noElements = (TextView) v.findViewById(R.id.no_elements);
avi = (AVLoadingIndicatorView) v.findViewById(R.id.avi);
avi.show();
// Get Transmissions
new GetTransmissions(mContext, this, getArguments().getString(KEY_DAY)).execute();
App application = (App) getActivity().getApplication();
Tracker mTracker = application.getDefaultTracker();
mTracker.setScreenName(getString(R.string.transmisions_view));
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
return v;
}
示例5: onCreate
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
mContext = this;
mActivity = this;
avi = (AVLoadingIndicatorView) findViewById(R.id.avi);
avi.show();
snackView = (View) findViewById(R.id.snackView);
launchGetStations(mContext, mActivity);
App application = (App) getApplication();
Tracker mTracker = application.getDefaultTracker();
mTracker.setScreenName(getString(R.string.splash_activity));
mTracker.send(new HitBuilders.ScreenViewBuilder().build());
}
示例6: getTracker
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
/**
* Gets the google analytics tracker.
*
* @return the google analytics tracker.
*/
private Tracker getTracker() {
if (mTracker == null) {
int checkExistence = mContext.getResources().getIdentifier("global_tracker", "xml", mContext.getPackageName());
if (checkExistence == 0) {
Log.e(AnalyticsManager.class.getCanonicalName(), "Please check if you have global-services.json");
} else {
mTracker = GoogleAnalytics.getInstance(mContext).newTracker(checkExistence);
mTracker.enableAutoActivityTracking(false);
mTracker.enableAdvertisingIdCollection(false);
mTracker.enableExceptionReporting(false);
}
}
return mTracker;
}
示例7: get
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
public synchronized Tracker get(Target target) {
if (!mTrackers.containsKey(target)) {
Tracker tracker;
switch (target) {
case APP:
tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
tracker.enableAdvertisingIdCollection(true);
break;
default:
throw new IllegalArgumentException("Unhandled analytics target " + target);
}
mTrackers.put(target, tracker);
}
return mTrackers.get(target);
}
示例8: setup
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
@Before
public void setup()
{
// Mock behavior for when Tracker.send(Map<String, String>) is called
tracker = mock(Tracker.class);
doAnswer(new Answer<Void>()
{
public Void answer(InvocationOnMock invocation)
{
Object[] args = invocation.getArguments();
//noinspection unchecked
testEventPropertiesMap = (Map<String, String>) args[0];
sendCalled = true;
return null;
}
}).when(tracker).send(anyMapOf(String.class, String.class));
provider = new GoogleAnalyticsProvider(tracker);
sendCalled = false;
testEventPropertiesMap = null;
}
示例9: deleteAppTrackersTest
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
@Test
public void deleteAppTrackersTest() throws Exception {
prepareMockedFields();
Analytics.prepareTrackersAndFbLogger(testShop, mockContext);
// Check size before deletion
HashMap<String, Tracker> trackersField = Whitebox.getInternalState(Analytics.class, "mTrackers");
assertEquals(trackersField.size(), 2);
// Tested method invocation
Analytics.deleteAppTrackers();
// Verify final size
trackersField = Whitebox.getInternalState(Analytics.class, "mTrackers");
assertEquals(trackersField.size(), 1);
}
示例10: sendEvent
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
public static void sendEvent(Tracker tracker, String category, String action, String label) {
if (tracker == null)
return;
if (category == null || category.isEmpty())
category = Utils.ANALYTICS_CATEGORY_ACTION;
HitBuilders.EventBuilder analyticsEvent = new HitBuilders.EventBuilder()
.setCategory(category)
.setAction(action);
if (label != null && !label.isEmpty())
analyticsEvent.setLabel(label);
tracker.send(analyticsEvent.build());
}
示例11: getDefaultTracker
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
synchronized public Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
// Чтобы включить ведение журнала отладки, используйте adb shell setprop log.tag.GAv4 DEBUG
mTracker = analytics.newTracker("global_tracker");
}
return mTracker;
}
示例12: get
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
public synchronized Tracker get(Target target) {
if (!mTrackers.containsKey(target)) {
Tracker tracker;
switch (target) {
case APP:
tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker);
break;
default:
throw new IllegalArgumentException("Unhandled analytics target " + target);
}
mTrackers.put(target, tracker);
}
return mTrackers.get(target);
}
示例13: trackException
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
public void trackException(Exception e) {
if (e != null) {
Tracker t = getGoogleAnalyticsTracker();
t.send(new HitBuilders.ExceptionBuilder()
.setDescription(
new StandardExceptionParser(this, null)
.getDescription(Thread.currentThread().getName(), e))
.setFatal(false)
.build()
);
}
}
示例14: getGATracker
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
synchronized static Tracker getGATracker(Context context) {
if (tracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
tracker = analytics.newTracker(R.xml.ga_app_tracker);
}
return tracker;
}
示例15: getDefaultTracker
import com.google.android.gms.analytics.Tracker; //导入依赖的package包/类
synchronized public Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
// To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
mTracker = analytics.newTracker(R.xml.app_tracker);
}
return mTracker;
}