/** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    /**
     * You should use try.count.ly instead of YOUR_SERVER for the line below if you are using
     * Countly trial service
     */
    Countly.sharedInstance()
        .init(this, "YOUR_SERVER", "YOUR_APP_KEY")
        .initMessaging(
            this,
            MainActivity.class,
            "YOUR_PROJECT_ID(NUMBERS ONLY)",
            Countly.CountlyMessagingMode.TEST);
    //                .setLocation(LATITUDE, LONGITUDE);
    //                .setLoggingEnabled(true);

    Countly.sharedInstance().recordEvent("test", 1);

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                Countly.sharedInstance().recordEvent("test2", 1, 2);
              }
            },
            5000);

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                Countly.sharedInstance().recordEvent("test3");
              }
            },
            10000);
  }
 @Override
 public void onStop() {
   Countly.sharedInstance().onStop();
   super.onStop();
 }
 @Override
 public void onStart() {
   super.onStart();
   Countly.sharedInstance().onStart(this);
 }