Back to project page android.
The source code is released under:
Apache License
If you think the Android project android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.digin.android; //from ww w . j a va 2 s .c om import android.app.Application; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.util.Log; import com.github.digin.android.constants.ParseKeys; import com.google.android.gms.analytics.GoogleAnalytics; import com.google.android.gms.analytics.Tracker; import com.parse.Parse; import java.util.HashMap; public class DiginApplication extends Application { HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>(); @Override public void onCreate() { super.onCreate(); PackageInfo pInfo = null; try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } String version = pInfo.versionName; int versionCode = pInfo.versionCode; Log.i("Digin", "Starting applicaton " + version + " | " + versionCode); Parse.initialize(this, ParseKeys.getAppId(this), ParseKeys.getClientKey(this)); // ACRA.init(this); } public synchronized Tracker getTracker(TrackerName trackerId) { if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = analytics.newTracker(getString(R.string.analytics_id)); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); } /** * Enum used to identify the tracker that needs to be used for tracking. * <p/> * A single tracker is usually enough for most purposes. In case you do need multiple trackers, * storing them all in Application object helps ensure that they are created only once per * application instance. */ public enum TrackerName { APP_TRACKER, // Tracker used only in this app. } }